Package org.omegazero.common.event
Class DelegatingTaskQueueExecutor
java.lang.Object
org.omegazero.common.event.AbstractTaskQueueExecutor
org.omegazero.common.event.DelegatingTaskQueueExecutor
An 
AbstractTaskQueueExecutor delegating all tasks to another AbstractTaskQueueExecutor implementation.
 This class is thread-safe.
- Since:
 - 2.12.0
 
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionbooleanexit(boolean blocking) Shuts thisAbstractTaskQueueExecutordown by gracefully stopping the worker threads.Returns the currently setAbstractTaskQueueExecutorto delegate tasks to.voidlock()Locks thisDelegatingTaskQueueExecutor.booleanQueues a task to be executed by any available worker thread.voidsetDelegate(AbstractTaskQueueExecutor delegate) Sets a newAbstractTaskQueueExecutorto delegate tasks to.voidsetErrorHandler(Consumer<Throwable> errorHandler) Sets the error handler that will be called when an error occurs while executing a task in any of the worker threads.booleanRemoves the given task from the queue.Methods inherited from class org.omegazero.common.event.AbstractTaskQueueExecutor
exit, queue, queue, queue 
- 
Constructor Details
- 
DelegatingTaskQueueExecutor
Creates a newDelegatingTaskQueueExecutor.- Parameters:
 delegate- TheAbstractTaskQueueExecutorto delegate tasks to
 
 - 
 - 
Method Details
- 
getDelegate
Returns the currently setAbstractTaskQueueExecutorto delegate tasks to.- Returns:
 - The current delegate
 
 - 
setDelegate
Sets a newAbstractTaskQueueExecutorto delegate tasks to.- Parameters:
 delegate- The newAbstractTaskQueueExecutor- Throws:
 IllegalStateException- If thisDelegatingTaskQueueExecutorwas locked usinglock()
 - 
lock
public void lock()Locks thisDelegatingTaskQueueExecutor. If locked, the delegate cannot be changed usingsetDelegate(AbstractTaskQueueExecutor)anymore.- Throws:
 IllegalStateException- If thisDelegatingTaskQueueExecutorwas locked already
 - 
queue
Description copied from class:AbstractTaskQueueExecutorQueues a task to be executed by any available worker thread.- Specified by:
 queuein classAbstractTaskQueueExecutor- Parameters:
 task- The task to queue- Returns:
 trueif the task was successfully queued- See Also:
 
 - 
unqueue
Description copied from class:AbstractTaskQueueExecutorRemoves the given task from the queue.- Specified by:
 unqueuein classAbstractTaskQueueExecutor- Parameters:
 task- The task to remove- Returns:
 trueif the task was queued previously and removed successfully- See Also:
 
 - 
exit
public boolean exit(boolean blocking) Description copied from class:AbstractTaskQueueExecutorShuts thisAbstractTaskQueueExecutordown by gracefully stopping the worker threads.- Specified by:
 exitin classAbstractTaskQueueExecutor- Parameters:
 blocking-trueto wait for all worker threads to exit- Returns:
 trueif the calling thread was interrupted while waiting for the worker threads to exit
 - 
setErrorHandler
Description copied from class:AbstractTaskQueueExecutorSets 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 error will be printed to
stderr.- Specified by:
 setErrorHandlerin classAbstractTaskQueueExecutor- Parameters:
 errorHandler- The error handler, ornullto remove an existing error handler
 
 -