T
- Type of tasks executed by this queue.public abstract class SequentialTaskQueue<T>
extends java.lang.Object
postTaskTermination()
after they are done
either successfully or with a failure.Modifier and Type | Field and Description |
---|---|
static int |
UNBOUNDED |
Modifier | Constructor and Description |
---|---|
protected |
SequentialTaskQueue(int initialCapacity,
int maxCapacity)
New instance.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
execute(T toExecute)
Executes the passed task and call
postTaskTermination() when the task has finished execution,
synchronously or asynchronously. |
boolean |
offerAndTryExecute(T task)
Adds the passed
task to this queue and triggers execution if there is no task currently executing. |
void |
postTaskTermination()
Callback to inform this queue that one of the task executed by this queue has terminated either successfully or
with a failure.
|
public static final int UNBOUNDED
protected SequentialTaskQueue(int initialCapacity, int maxCapacity)
initialCapacity
- Initial capacity for the queue.maxCapacity
- Optional maximum capacity. UNBOUNDED
if the queue needs to be unbounded.public boolean offerAndTryExecute(T task)
task
to this queue and triggers execution if there is no task currently executing.task
- to execute.true
if the task was successfully added to this queue.public final void postTaskTermination()
protected abstract void execute(T toExecute)
postTaskTermination()
when the task has finished execution,
synchronously or asynchronously.toExecute
- Task to execute.