| java.lang.Object com.sun.perseus.util.Scheduler
Scheduler | final class Scheduler (Code) | | This class is used to multiplex Runnables that need to be
run at a fixed rate.
version: $Id: Scheduler.java,v 1.3 2006/04/21 06:35:54 st125089 Exp $ |
Inner Class :final static class Entry | |
Field Summary | |
Entry[] | entries The current list of Runnables scheduled at a fixed interval. | RunnableQueue | rq The associated RunnableQueue. |
Constructor Summary | |
| Scheduler(RunnableQueue rq) Builds a new Scheduler for the given RunnableQueue.
Parameters: rq - the associated RunnableQueue. |
Method Summary | |
public synchronized void | add(Runnable r, long interval, RunnableHandler handler) Adds a new Runnable to be run at the requested fixed interval. | public synchronized long | nextRun(long currentTime) Parameters: currentTime - the current time, in milliseconds. | public synchronized void | remove(Runnable r) Removes a Runnable from the list of Runnables that are scheduled
at a fixed interval. | public synchronized void | run(long currentTime) Runs the scheduled Runnables that are due or overdue. |
entries | Entry[] entries(Code) | | The current list of Runnables scheduled at a fixed interval.
|
Scheduler | Scheduler(RunnableQueue rq)(Code) | | Builds a new Scheduler for the given RunnableQueue.
Parameters: rq - the associated RunnableQueue. Should not be null. |
add | public synchronized void add(Runnable r, long interval, RunnableHandler handler)(Code) | | Adds a new Runnable to be run at the requested fixed interval. Note that
if the input Runnable is entered multiple times into the scheduler, it
will be run once for each interval it is registered with.
Parameters: r - the Runnable to run at a fixed rate. Should not be null. Parameters: interal - the interval, in milliseconds, between runs of the Runnable. Should be strictly positive. Parameters: handler - the associated RunHandler, which should be notifiedwhen the Runnable is actually run. May be null. |
nextRun | public synchronized long nextRun(long currentTime)(Code) | | Parameters: currentTime - the current time, in milliseconds. the time until the next scheduled Runnable needs to be run.Returns -1 if there is no scheduled Runnable. |
remove | public synchronized void remove(Runnable r)(Code) | | Removes a Runnable from the list of Runnables that are scheduled
at a fixed interval. If the Runnable was registered multiple times
with this scheduler, all instances are removed.
Parameters: r - the Runnable to removed from the list of Runnables scheduledat a fixed rate. |
run | public synchronized void run(long currentTime)(Code) | | Runs the scheduled Runnables that are due or overdue.
Parameters: currentTime - the currentTime when this runnable is ran. |
|
|