Class EventQueueExecutor

java.lang.Object
org.omegazero.common.event.EventQueue
org.omegazero.common.event.EventQueueExecutor

@Deprecated public class EventQueueExecutor extends EventQueue
Deprecated.
Since 2.6. Use a TaskQueueExecutor with a BlockingQueue instead.
Executor for EventQueues.
  • Constructor Details

    • EventQueueExecutor

      public EventQueueExecutor()
      Deprecated.
      Default values:
      maxThreads: Number of processors
      daemon: true
      threadName: "EventQueueExecutor"
      See Also:
    • EventQueueExecutor

      public EventQueueExecutor(boolean daemon)
      Deprecated.
      Default values:
      maxThreads: Number of processors
      threadName: "EventQueueExecutor"
      See Also:
    • EventQueueExecutor

      public EventQueueExecutor(int maxThreads)
      Deprecated.
      Default values:
      daemon: true
      threadName: "EventQueueExecutor"
      See Also:
    • EventQueueExecutor

      public EventQueueExecutor(int maxThreads, boolean daemon)
      Deprecated.
      Default values:
      threadName: "EventQueueExecutor"
      See Also:
    • EventQueueExecutor

      public EventQueueExecutor(boolean daemon, String threadName)
      Deprecated.
      Default values:
      maxThreads: Number of processors
      threadName: "EventQueueExecutor"
      See Also:
    • EventQueueExecutor

      public EventQueueExecutor(int maxThreads, boolean daemon, String threadName)
      Deprecated.
      Creates a new EventQueue with built-in executor threads that call EventQueue.execute(). Additionally, if a task is taking too long to complete and another task was queued, another worker thread will be spawned to concurrently execute the new task.

      If daemon is true, the worker threads will be set as daemon threads. Otherwise, exit() will need to be explicitly called to complete remaining tasks and exit the worker threads.
      Parameters:
      maxThreads - The maximum number of worker threads to spawn
      daemon - If worker threads should be set as daemon threads
      threadName - The name of the worker threads, appended with a unique number
  • Method Details

    • queue

      public void queue(Task task)
      Deprecated.
      Description copied from class: EventQueue
      Queues a task to be executed in a subsequent EventQueue.execute() call. Tasks with the highest value for Task#priority will be executed first.

      A thread waiting on this queue's monitor will be notified.
      Overrides:
      queue in class EventQueue
      Parameters:
      task - The task to queue
    • checkWorkers

      public void checkWorkers()
      Deprecated.
      Ensures that there are enough worker threads available for executing queued tasks.
      If not, and the number of running threads is lower than maxThreads, a new worker thread will be created.
    • exit

      public void exit()
      Deprecated.
      Default values:
      blocking: false
      See Also:
    • exit

      public void exit(boolean blocking)
      Deprecated.
      Notifies worker threads that executor is exiting, causing them to complete running all tasks.
      Parameters:
      blocking - If true, block the calling thread until all worker threads have exited
    • getMaxThreads

      public int getMaxThreads()
      Deprecated.
      Returns:
      The maximum number of worker threads allowed to be created
    • getWorkerThreadCount

      public int getWorkerThreadCount()
      Deprecated.
      Returns:
      Number of running worker threads
    • setErrorHandler

      public void setErrorHandler(Consumer<Throwable> errorHandler)
      Deprecated.
      Sets the error handler that will be called when an error occurs while executing a task in any of the worker threads.

      If this handler is not set, the worker thread will exit, otherwise, the handler may choose to ignore the error and continue.
      Parameters:
      errorHandler - The error handler