Interface ThreadContext

All Superinterfaces:
AutoCloseable, CloseableSilently, Executor, Scheduler
All Known Implementing Classes:
SingleThreadContext

public interface ThreadContext extends CloseableSilently, Executor, Scheduler
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 Type
    Method
    Description
    default void
    Checks that the current thread is the correct context thread.
    default void
    By default there are no resources to close.
    Returns the current thread context.

    Methods inherited from interface java.util.concurrent.Executor

    execute

    Methods inherited from interface io.atomix.utils.concurrent.Scheduler

    schedule, schedule, schedule, schedule
  • Method Details

    • currentContext

      static ThreadContext currentContext()
      Returns the current thread context.
      Returns:
      The current thread context or null if 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:
      close in interface AutoCloseable
      Specified by:
      close in interface CloseableSilently
      Specified by:
      close in interface Scheduler