|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.sgs.impl.kernel.schedule.FIFOSchedulerQueue
public class FIFOSchedulerQueue
This is a simple implemenation of SchedulerQueue that
accepts tasks and runs them in the order that they are ready. No attempt
is made to support priority, or to provide any degree of fairness
between users. This class uses an un-bounded queue. Unless the system
runs out of memory, this should always accept any tasks from any user.
| Constructor Summary | |
|---|---|
FIFOSchedulerQueue(Properties properties)
Creates an instance of FIFOSchedulerQueue. |
|
| 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 FIFOSchedulerQueue(Properties properties)
FIFOSchedulerQueue.
properties - the available system 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 | |||||||||