public interface ExecController extends AutoCloseable
The instance for an application can be obtained via the server registry.
Modifier and Type | Method and Description |
---|---|
default void |
awaitShutdown()
Waits a maximum of 60 seconds for this execution controller to shut down.
|
default void |
awaitShutdown(Duration duration)
Waits the given amount of time for this execution controller to completely shut down.
|
void |
close()
Shuts down this controller, terminating the event loop and blocking threads.
|
static Optional<ExecController> |
current()
Returns the execution controller bound to the current thread, if this is a Ratpack managed compute thread.
|
ExecStarter |
fork() |
ExecutorService |
getBlockingExecutor() |
EventLoopGroup |
getEventLoopGroup()
The event loop group used by Netty for this application.
|
ScheduledExecutorService |
getExecutor()
The event loop (i.e.
|
int |
getNumThreads()
The number of threads that will be used for computation.
|
static ExecController |
require()
Returns the execution controller bound to the current thread, or throws an exception if called on a non Ratpack managed compute thread.
|
static Optional<ExecController> current()
If called on a non Ratpack compute thread, the returned optional will be empty.
static ExecController require() throws UnmanagedThreadException
If called on a non Ratpack compute thread, the returned optional will be empty.
UnmanagedThreadException
- when called from a non Ratpack managed threadExecStarter fork()
ScheduledExecutorService getExecutor()
This executor wraps Netty's event loop executor to provide callback features by way of Guava's executor extensions.
It is generally preferable to use fork()
to submit computation work rather than this method,
which properly initialises Ratpack's execution infrastructure.
ExecutorService getBlockingExecutor()
EventLoopGroup getEventLoopGroup()
Generally there is no need to access this unless you are doing something directly with Netty.
int getNumThreads()
This is determined by the ServerConfig.getThreads()
value of the launch config that created this controller.
void close()
This method returns immediately, not waiting for the actual shutdown to occur.
Generally, the only time it is necessary to call this method is when using an exec controller directly during testing.
Calling RatpackServer.stop()
will inherently call this method.
close
in interface AutoCloseable
default void awaitShutdown() throws InterruptedException
InterruptedException
- if shutdown does not occur in timeawaitShutdown(Duration)
default void awaitShutdown(Duration duration) throws InterruptedException
duration
- the amount of time to wait for shutdownInterruptedException
- if shutdown does not occur in time