|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.samskivert.util.Interval
public abstract class Interval
An interface for doing operations after some delay. Allows expiration to occur on a specific thread, and guarantees that any queued expiration will not run if the Interval has since been cancelled or rescheduled.
| Nested Class Summary | |
|---|---|
protected static class |
Interval.IntervalTask
The task that schedules actually runs the interval. |
static interface |
Interval.RunBuddy
An interface that will be implemented by the runnable posted to a RunQueue that can be used to retrieve the original Interval. |
| Field Summary | |
|---|---|
protected RunQueue |
_runQueue
If non-null, the RunQueue used to run the expired() method for each Interval. |
protected Interval.IntervalTask |
_task
The task that actually schedules our execution with the static Timer. |
protected static Timer |
_timer
The daemon timer used to schedule all intervals. |
| Constructor Summary | |
|---|---|
Interval()
Create a simple interval that does not use a RunQueue to run the expired() method. |
|
Interval(RunQueue runQueue)
Create an Interval that uses the specified RunQueue to run the expired()
method. |
|
| Method Summary | |
|---|---|
void |
cancel()
Cancel the current schedule, and ensure that any expirations that are queued up but have not yet run do not run. |
protected static Timer |
createTimer()
|
abstract void |
expired()
The main method where your interval should do its work. |
static void |
resetTimer()
Deprecated. |
protected void |
safelyExpire(Interval.IntervalTask task)
Safely expire the interval. |
void |
schedule(Date when)
Schedules this interval to execute once at when. |
void |
schedule(long delay)
Schedule the interval to execute once, after the specified delay. |
void |
schedule(long delay,
boolean repeat)
Schedule the interval to execute repeatedly with fixed-rate scheduling between repeats, with the same delay. |
void |
schedule(long initialDelay,
long repeatDelay)
Schedule the interval to execute repeatedly with the specified initial delay and repeat delay with fixed-rate scheduling between repeats. |
void |
schedule(long initialDelay,
long repeatDelay,
boolean fixedRate)
Schedule the interval to execute repeatedly with the specified initial delay and repeat delay. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected RunQueue _runQueue
protected volatile Interval.IntervalTask _task
protected static Timer _timer
| Constructor Detail |
|---|
public Interval()
expired() method.
public Interval(RunQueue runQueue)
RunQueue to run the expired()
method. If null is supplied the interval will be run directly on the timer thread.
| Method Detail |
|---|
@Deprecated public static void resetTimer()
public abstract void expired()
public final void schedule(Date when)
when. Supersedes any previous
schedule that this Interval may have had.
public final void schedule(long delay)
public final void schedule(long delay,
boolean repeat)
public final void schedule(long initialDelay,
long repeatDelay)
public final void schedule(long initialDelay,
long repeatDelay,
boolean fixedRate)
fixedRate - - if true, this interval schedules repeated expirations using
Timer.scheduleAtFixedRate(TimerTask, long, long) ensuring that the number of
expired calls will match the amount of time elapsed. If false, it uses
Timer.schedule(TimerTask, long, long) which ensures that there will be close to
repeateDelay milliseconds between expirations.
IllegalArgumentException - if fixedRate is false and a RunQueue has been specified.
That doesn't make sense because the fixed delay cannot account for the time that the
RunBuddy sits on the RunQueue waiting to call expire().public final void cancel()
protected final void safelyExpire(Interval.IntervalTask task)
protected static Timer createTimer()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||