public interface InternalTaskQueue extends TaskQueue
TaskScheduler
.
Methods in this interface are expected to be called concurrently. For example, tasks may be added to or removed from
the queue while a scheduling iteration using this queue is in progress. Implementations must handle this. Note that,
it may not be sufficient for the implementations to use concurrent versions of collection classes for queue of tasks.
The queue must be consistent throughout the scheduling iteration. One recommended way to achieve such consistency is
to place the TaskQueue.queueTask(QueuableTask)
operations as requests in a holding area within the implementation and
return immediately. Later, actually carry them out during the reset()
method.
TaskQueue.TaskState
Modifier and Type | Method and Description |
---|---|
java.util.Map<TaskQueue.TaskState,java.util.Collection<QueuableTask>> |
getAllTasks()
Get all of the tasks in the queue.
|
UsageTrackedQueue |
getUsageTracker()
Get the usage tracker, if any.
|
boolean |
reset()
Reset the queue and make it ready for next scheduling iteration.
|
next
boolean reset() throws TaskQueueMultiException
true
if the queue was changed as part of this operation, false
otherwise. The queue is
deemed changed if any queue modifications that were held for safety are carried out during this method, such as
adding to or removing from the queue.TaskQueueMultiException
- If any exceptions that may have occurred during resetting the pointer to the head
of the queue. Or, this may include exceptions that arose when applying any deferred operations from
TaskQueue.queueTask(QueuableTask)
method.UsageTrackedQueue getUsageTracker()
TaskScheduler
will call the appropriate methods of the tracker
as scheduling assignments are taking place. This can help the queue implementations, for example, in maintaining
any fairness for resource usage across multiple entities within the queue. If this method returns
null
, then the scheduler will ignore usage tracking for this queue.
Note that the implementations of UsageTrackedQueue
must be efficient since they are called from
within the scheduling iteration.
java.util.Map<TaskQueue.TaskState,java.util.Collection<QueuableTask>> getAllTasks() throws TaskQueueException
Map
with TaskState
as key and Collection
of
QueuableTask
as values.TaskQueueException
- when called concurrently with a scheduling iteration in progress.