Class EventLoopGroupFactory

java.lang.Object
org.neo4j.driver.internal.async.connection.EventLoopGroupFactory

public final class EventLoopGroupFactory extends Object
Manages creation of Netty EventLoopGroups, which are basically Executors that perform IO operations.
  • Method Details

    • channelClass

      public static Class<? extends io.netty.channel.Channel> channelClass()
      Get class of Channel for AbstractBootstrap.channel(Class) method.
      Returns:
      class of the channel, which should be consistent with EventLoopGroups returned by newEventLoopGroup(int).
    • newEventLoopGroup

      public static io.netty.channel.EventLoopGroup newEventLoopGroup(int threadCount)
      Create new EventLoopGroup with specified thread count. Returned group should by given to AbstractBootstrap.group(EventLoopGroup).
      Parameters:
      threadCount - amount of IO threads for the new group.
      Returns:
      new group consistent with channel class returned by channelClass().
    • assertNotInEventLoopThread

      public static void assertNotInEventLoopThread() throws IllegalStateException
      Assert that current thread is not an event loop used for async IO operations. This check is needed because blocking API methods like SimpleQueryRunner.run(String) are implemented on top of corresponding async API methods like AsyncQueryRunner.runAsync(String) using basically Future.get() calls. Deadlocks might happen when IO thread executes blocking API call and has to wait for itself to read from the network.
      Throws:
      IllegalStateException - when current thread is an event loop IO thread.
    • isEventLoopThread

      public static boolean isEventLoopThread(Thread thread)
      Check if given thread is an event loop IO thread.
      Parameters:
      thread - the thread to check.
      Returns:
      true when given thread belongs to the event loop, false otherwise.