APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing

pack-priv Class TimerQueue

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.util.concurrent.*, java.util.concurrent.locks.*, java.util.concurrent.atomic.AtomicLong, sun.awt.util.ThreadGroupUtils

Internal class to manage all Timers using one thread. TimerQueue manages a queue of Timers. The Timers are chained together in a linked list sorted by the order in which they will expire.
Authors
Dave Moore, Igor Kushnirskiy

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final Object
private static final long
NANO_ORIGIN

Base of nanosecond timings, to avoid wrapping

private final DelayQueue<TimerQueue.DelayedTimer>
private volatile boolean
private final Lock
private static volatile TimerQueue

Constructor Summary

AccessConstructor and Description
public
TimerQueue()

Constructor for TimerQueue.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
addTimer(Timer timer, long delayMillis)

private void
pack-priv boolean
private static long
now()

Returns nanosecond time offset by origin

pack-priv void
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

public static TimerQueue
pack-priv void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

classLockback to summary
private static final Object classLock
NANO_ORIGINback to summary
private static final long NANO_ORIGIN

Base of nanosecond timings, to avoid wrapping

queueback to summary
private final DelayQueue<TimerQueue.DelayedTimer> queue
runningback to summary
private volatile boolean running
runningLockback to summary
private final Lock runningLock
sharedInstanceback to summary
private static volatile TimerQueue sharedInstance

Constructor Detail

TimerQueueback to summary
public TimerQueue()

Constructor for TimerQueue.

Method Detail

addTimerback to summary
pack-priv void addTimer(Timer timer, long delayMillis)
addTimerback to summary
private void addTimer(TimerQueue.DelayedTimer delayedTimer)
containsTimerback to summary
pack-priv boolean containsTimer(Timer timer)
nowback to summary
private static long now()

Returns nanosecond time offset by origin

removeTimerback to summary
pack-priv void removeTimer(Timer timer)
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

sharedInstanceback to summary
public static TimerQueue sharedInstance()
startIfNeededback to summary
pack-priv void startIfNeeded()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

javax.swing back to summary

pack-priv Class TimerQueue.DelayedTimer

extends Object
implements Delayed
Class Inheritance
All Implemented Interfaces
java.util.concurrent.Delayed, java.lang.Comparable

Field Summary

Modifier and TypeField and Description
private final long
sequenceNumber

Sequence number to break ties FIFO

private static final AtomicLong
sequencer

Sequence number to break scheduling ties, and in turn to guarantee FIFO order among tied entries.

private volatile long
time

The time the task is enabled to execute in nanoTime units

private final Timer

Constructor Summary

AccessConstructor and Description
pack-priv
DelayedTimer(Timer timer, long nanos)

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(Delayed other)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

public final long
getDelay(TimeUnit unit)

Implements java.util.concurrent.Delayed.getDelay.

Returns the remaining delay associated with this object, in the given time unit.

pack-priv final Timer
pack-priv final void
setTime(long nanos)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

sequenceNumberback to summary
private final long sequenceNumber

Sequence number to break ties FIFO

sequencerback to summary
private static final AtomicLong sequencer

Sequence number to break scheduling ties, and in turn to guarantee FIFO order among tied entries.

timeback to summary
private volatile long time

The time the task is enabled to execute in nanoTime units

timerback to summary
private final Timer timer

Constructor Detail

DelayedTimerback to summary
pack-priv DelayedTimer(Timer timer, long nanos)

Method Detail

compareToback to summary
public int compareTo(Delayed other)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

getDelayback to summary
public final long getDelay(TimeUnit unit)

Implements java.util.concurrent.Delayed.getDelay.

Doc from java.util.concurrent.Delayed.getDelay.

Returns the remaining delay associated with this object, in the given time unit.

getTimerback to summary
pack-priv final Timer getTimer()
setTimeback to summary
pack-priv final void setTime(long nanos)