Package org.omegazero.common.event
Class EventQueueExecutor
java.lang.Object
org.omegazero.common.event.EventQueue
org.omegazero.common.event.EventQueueExecutor
Deprecated.
Executor for
EventQueue
s.-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Default values:
maxThreads: Number of processors
daemon: true
threadName: "EventQueueExecutor"EventQueueExecutor
(boolean daemon) Deprecated.Default values:
maxThreads: Number of processors
threadName: "EventQueueExecutor"EventQueueExecutor
(boolean daemon, String threadName) Deprecated.Default values:
maxThreads: Number of processors
threadName: "EventQueueExecutor"EventQueueExecutor
(int maxThreads) Deprecated.Default values:
daemon: true
threadName: "EventQueueExecutor"EventQueueExecutor
(int maxThreads, boolean daemon) Deprecated.Default values:
threadName: "EventQueueExecutor"EventQueueExecutor
(int maxThreads, boolean daemon, String threadName) Deprecated.Creates a new EventQueue with built-in executor threads that callEventQueue.execute()
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.Ensures that there are enough worker threads available for executing queued tasks.void
exit()
Deprecated.Default values:
blocking: falsevoid
exit
(boolean blocking) Deprecated.Notifies worker threads that executor is exiting, causing them to complete running all tasks.int
Deprecated.int
Deprecated.void
Deprecated.Queues a task to be executed in a subsequentEventQueue.execute()
call.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.Methods inherited from class org.omegazero.common.event.EventQueue
clearTasks, execute, executeBlocking, getNextTask, getQueuedTaskCount, isTaskQueued, queue, queue, waitForTask
-
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
Deprecated.Default values:
maxThreads: Number of processors
threadName: "EventQueueExecutor"- See Also:
-
EventQueueExecutor
Deprecated.Creates a new EventQueue with built-in executor threads that callEventQueue.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 spawndaemon
- If worker threads should be set as daemon threadsthreadName
- The name of the worker threads, appended with a unique number
-
-
Method Details
-
queue
Deprecated.Description copied from class:EventQueue
Queues a task to be executed in a subsequentEventQueue.execute()
call. Tasks with the highest value forTask#priority
will be executed first.
A thread waiting on this queue's monitor will be notified.- Overrides:
queue
in classEventQueue
- 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
- Iftrue
, 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
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
-
TaskQueueExecutor
with aBlockingQueue
instead.