- All Known Subinterfaces:
VertxReactor
A reactor defines the core threading model and more specifically it provides the main event loop used at the core of Inverno's applications.
A reactor exposes a single acceptor event loop group used to accept connection and methods to create event loop groups backed by a unique core event loop group in order to optimize thread creation and usage based on hardware and software capabilities.
- Since:
- 1.2
- Author:
- Jeremy Kuhn
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A marker interface that is detected onThreads
to indicate that a thread is part of a reactor. -
Method Summary
Modifier and TypeMethodDescriptionCreates an IO event loop group with all available threads.createIoEventLoopGroup
(int nThreads) Creates an IO event loop group with the specified amount of threads.Returns the event loop associated to the current thread.Returns the acceptor event loop group typically with one thread.int
Returns the size of the core IO event loop group.Returns an event loop from the core IO event loop group.Returns the worker pool.
-
Method Details
-
eventLoop
Returns the event loop associated to the current thread.
- Returns:
- an optional returning the current event loop or an empty optional if the current thread is not a reactor thread.
-
getWorkerPool
ExecutorService getWorkerPool()Returns the worker pool.
The worker pool is typically used to execute blocking task outside the I/O event loop.
- Returns:
- an executor service
-
getAcceptorEventLoopGroup
EventLoopGroup getAcceptorEventLoopGroup()Returns the acceptor event loop group typically with one thread.
This event loop group should be shared across network servers to accept connections.
- Returns:
- an acceptor event loop group
-
createIoEventLoopGroup
EventLoopGroup createIoEventLoopGroup()Creates an IO event loop group with all available threads.
- Returns:
- an IO event loop group
-
createIoEventLoopGroup
Creates an IO event loop group with the specified amount of threads.
- Parameters:
nThreads
- the number of threads to allocate- Returns:
- an IO event loop group
- Throws:
IllegalArgumentException
- if the specified number of thread exceeds the number of threads available
-
getEventLoop
EventLoop getEventLoop()Returns an event loop from the core IO event loop group.
- Returns:
- an event loop
-
getCoreIoEventLoopGroupSize
int getCoreIoEventLoopGroupSize()Returns the size of the core IO event loop group.
This basically the maximum number of threads one can allocate to an IO event loop group.
- Returns:
- The number of threads allocated to the core IO event loop group
-