|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface SchedulerQueue
This interface is used to define the backing queue for a scheduler. Essentially, implementations are used to define some policy for ordering task execution.
All implementations must implement a constructor of the form
(java.util.Properties).
| Method Summary | |
|---|---|
void |
addTask(ScheduledTask task)
Adds a task to the scheduler. |
RecurringTaskHandle |
createRecurringTaskHandle(ScheduledTask task)
Creates a RecurringTaskHandle for the associated task. |
ScheduledTask |
getNextTask(boolean wait)
Returns the next task to run, blocking if wait is true. |
int |
getNextTasks(Collection<? super ScheduledTask> tasks,
int max)
Places at most the next max tasks available into
the provided Collection. |
int |
getReadyCount()
Returns the number of tasks that are ready to run. |
void |
notifyCancelled(ScheduledTask task)
Notifies the scheduler that the given task has been cancelled. |
TaskReservation |
reserveTask(ScheduledTask task)
Reserves a space for a task. |
void |
shutdown()
Tells this SchedulerQueue to shutdown. |
| Method Detail |
|---|
int getReadyCount()
ScheduledTask getNextTask(boolean wait)
throws InterruptedException
wait is true.
If not waiting, it returns null if nothing is available.
wait - whether to wait for a task to become available
ScheduledTask or null
InterruptedException - if the thread is interrupted while
waiting for a task
int getNextTasks(Collection<? super ScheduledTask> tasks,
int max)
max tasks available into
the provided Collection. This method does not block,
so it may not provide any tasks. The number of tasks provided
is returned.
Note that there is no guarentee that the tasks provided are all
contiguous. That is, if two calls are made at the same time to this
method, or a call to getNextTask is made at the same
time, the scheduler does not have to provide the next max
tasks to one consumer before servicing others. If this behavior is
needed, the caller needs to synchronize access. The tasks are
guaranteed to be in correct order if the provided Collection
is ordered.
tasks - the Collection into which the tasks are putmax - the maximum number of tasks to get
TaskReservation reserveTask(ScheduledTask task)
task - the ScheduledTask to reserve
TaskReservation for the task
TaskRejectedException - if a reservation cannot be made, or if
the task is recurringvoid addTask(ScheduledTask task)
Note that if this is a recurring task, then a call to its
getRecurringTaskHandle method must return a handle provided
by a call to this implementation's createRecurringTaskHandle
method. Note also that it is up to the caller to re-schedule this
task for each recurrence, and that each such call must provide a
unique instance of ScheduledTask.
task - the ScheduledTask to add
TaskRejectedException - if the task cannot be addedRecurringTaskHandle createRecurringTaskHandle(ScheduledTask task)
RecurringTaskHandle for the associated task. The
associated task will not actually be available through this queue
until start is called on the returned handle. The
ScheduledTask instance must never have been previously used
to schedule a recurring task. Note that after the initial execution
of this task, it is up to the caller to schedule each recurrence
through a call to addTask.
task - the ScheduledTask to run recurringly
RecurringTaskHandle that manages the task
IllegalArgumentException - if the task has already been scheduled
as a recurring taskvoid notifyCancelled(ScheduledTask task)
task - the ScheduledTask that has been cancelledvoid shutdown()
SchedulerQueue to shutdown.
|
RedDwarf, Version 0.10.1 2010-03-14 10:56:12 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||