public interface ThreadContext extends AutoCloseable, Executor, Scheduler
The thread context is used by Catalyst 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.
| Modifier and Type | Method and Description |
|---|---|
default void |
checkThread()
Checks that the current thread is the correct context thread.
|
void |
close()
Closes the context.
|
static ThreadContext |
currentContext()
Returns the current thread context.
|
static ThreadContext |
currentContextOrThrow() |
default boolean |
isCurrentContext()
Returns a boolean indicating whether the current thread is in this context.
|
static ThreadContext currentContext()
null if no context exists.static ThreadContext currentContextOrThrow()
IllegalStateException - if the current thread is not a catalyst threaddefault boolean isCurrentContext()
default void checkThread()
void close()
close in interface AutoCloseableCopyright © 2013–2017. All rights reserved.