Module org.neo4j.driver
Class EventLoopGroupFactory
java.lang.Object
org.neo4j.driver.internal.async.connection.EventLoopGroupFactory
Manages creation of Netty
EventLoopGroup
s, which are basically Executor
s that perform IO operations.-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Assert that current thread is not an event loop used for async IO operations.static Class<? extends io.netty.channel.Channel>
Get class ofChannel
forAbstractBootstrap.channel(Class)
method.static boolean
isEventLoopThread
(Thread thread) Check if given thread is an event loop IO thread.static io.netty.channel.EventLoopGroup
newEventLoopGroup
(int threadCount) Create newEventLoopGroup
with specified thread count.
-
Method Details
-
channelClass
Get class ofChannel
forAbstractBootstrap.channel(Class)
method.- Returns:
- class of the channel, which should be consistent with
EventLoopGroup
s returned bynewEventLoopGroup(int)
.
-
newEventLoopGroup
public static io.netty.channel.EventLoopGroup newEventLoopGroup(int threadCount) Create newEventLoopGroup
with 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:
true
when given thread belongs to the event loop,false
otherwise.
-