Package io.atomix.utils.concurrent
Interface ThreadContext
- All Superinterfaces:
AutoCloseable,CloseableSilently,Executor,Scheduler
- All Known Implementing Classes:
SingleThreadContext
Thread context.
The thread context is used by Atomix to determine the correct thread on which to execute
asynchronous callbacks. All threads created within Catalyst must be instances of AtomixThread. Once a thread has been created, the context is stored in the thread object via
AtomixThread.setContext(ThreadContext). This means there is a one-to-one relationship
between a context and a thread. That is, a context is representative of a thread and provides an
interface for firing events on that thread.
Components of the framework that provide custom threads should use AtomixThreadFactory
to allocate new threads and provide a custom ThreadContext implementation.
- Author:
- Jordan Halterman
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidChecks that the current thread is the correct context thread.default voidclose()By default there are no resources to close.static ThreadContextReturns the current thread context.
-
Method Details
-
currentContext
Returns the current thread context.- Returns:
- The current thread context or
nullif no context exists.
-
checkThread
default void checkThread()Checks that the current thread is the correct context thread. -
close
default void close()By default there are no resources to close.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseableSilently- Specified by:
closein interfaceScheduler
-