Module org.neo4j.driver
Class EventLoopGroupFactory
java.lang.Object
org.neo4j.driver.internal.bolt.basicimpl.async.connection.EventLoopGroupFactory
Manages creation of Netty
EventLoopGroups, which are basically Executors that perform IO operations.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidAssert that current thread is not an event loop used for async IO operations.static Class<? extends io.netty.channel.Channel>Get class ofChannelforAbstractBootstrap.channel(Class)method.static booleanisEventLoopThread(Thread thread) Check if given thread is an event loop IO thread.static io.netty.channel.EventLoopGroupnewEventLoopGroup(int threadCount) Create newEventLoopGroupwith specified thread count.
-
Method Details
-
channelClass
Get class ofChannelforAbstractBootstrap.channel(Class)method.- Returns:
- class of the channel, which should be consistent with
EventLoopGroups returned bynewEventLoopGroup(int).
-
newEventLoopGroup
public static io.netty.channel.EventLoopGroup newEventLoopGroup(int threadCount) Create newEventLoopGroupwith specified thread count. Returned group should by given toAbstractBootstrap.group(EventLoopGroup).- Parameters:
threadCount- amount of IO threads for the new group.- Returns:
- new group consistent with channel class returned by
channelClass().
-
assertNotInEventLoopThread
Assert that current thread is not an event loop used for async IO operations. This check is needed because blocking API methods likeSimpleQueryRunner.run(String)are implemented on top of corresponding async API methods likeAsyncQueryRunner.runAsync(String)using basicallyFuture.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
Check if given thread is an event loop IO thread.- Parameters:
thread- the thread to check.- Returns:
truewhen given thread belongs to the event loop,falseotherwise.
-