|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.sgs.impl.kernel.schedule.WindowSchedulerQueue
public class WindowSchedulerQueue
This implementation of SchedulerQueue tries to
provide fairness between users without taking too long to service any
given user's tasks. This is typified by the phrase "no one gets seconds
until everyone who wants them has had firsts."
The implementation uses a priority queue, keyed off what is called a window value. Users submit tasks into increasing window values, and may never submit tasks into windows that have already passed.
| Constructor Summary | |
|---|---|
WindowSchedulerQueue(Properties properties)
Creates an instance of WindowSchedulerQueue. |
|
| 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. |
void |
timedTaskReady(ScheduledTask task)
Called when a delayed task has reached its time to run. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WindowSchedulerQueue(Properties properties)
WindowSchedulerQueue.
properties - the application Properties| Method Detail |
|---|
public int getReadyCount()
getReadyCount in interface SchedulerQueue
public ScheduledTask getNextTask(boolean wait)
throws InterruptedException
wait is true.
If not waiting, it returns null if nothing is available.
getNextTask in interface SchedulerQueuewait - whether to wait for a task to become available
ScheduledTask or null
InterruptedException - if the thread is interrupted while
waiting for a task
public 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.
getNextTasks in interface SchedulerQueuetasks - the Collection into which the tasks are putmax - the maximum number of tasks to get
public TaskReservation reserveTask(ScheduledTask task)
reserveTask in interface SchedulerQueuetask - the ScheduledTask to reserve
TaskReservation for the taskpublic void 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.
addTask in interface SchedulerQueuetask - the ScheduledTask to addpublic RecurringTaskHandle 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.
createRecurringTaskHandle in interface SchedulerQueuetask - the ScheduledTask to run recurringly
RecurringTaskHandle that manages the taskpublic void notifyCancelled(ScheduledTask task)
notifyCancelled in interface SchedulerQueuetask - the ScheduledTask that has been cancelledpublic void timedTaskReady(ScheduledTask task)
timedTaskReady in interface TimedTaskListenertask - the ScheduledTask that is ready to runpublic void shutdown()
SchedulerQueue to shutdown.
shutdown in interface SchedulerQueue
|
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 | |||||||||