abstract class TransitionWatcher extends Object implements Comparable<TransitionWatcher>
TransitionWatcher has a
time stamp and when compared TransitionWatchers with a
lower time stamp are considered less than those with a larger time
stamp. If two TransitionWatcher have the same time
stamp their tie breaker values are used.
Unless otherwise noted, the addTemplateHandle method must
be called at least once before any other method.
Some implementations of this call only support calling
addTemplateHandle once on any particular instance.
Unless otherwise noted, all the package protected methods are thread safe.
| Modifier and Type | Field and Description |
|---|---|
private static java.util.concurrent.atomic.AtomicLong |
nextTiebreaker
Next tiebreaker to use
|
(package private) long |
startOrdinal
The transitions with higher ordinals occurred
after the operation associated with this
watcher was started.
|
private long |
tiebreaker
The tie breaker for this object
|
private long |
timestamp
The time stamp for this object
|
| Constructor and Description |
|---|
TransitionWatcher(long timestamp,
long startOrdinal)
Create a new
TransitionWatcher. |
| Modifier and Type | Method and Description |
|---|---|
(package private) abstract boolean |
addTemplateHandle(TemplateHandle h)
Associate a
TemplateHandle with this object. |
int |
compareTo(TransitionWatcher o)
Compares this object with another.
|
abstract long |
getExpiration()
Get the expiration time of this object.
|
(package private) abstract boolean |
isInterested(EntryTransition transition,
long ordinal)
Return
true if this watcher cares about a given
visibility transition. |
(package private) abstract void |
process(EntryTransition transition,
long now)
Process the given transition.
|
(package private) abstract void |
removeIfExpired(long now)
Remove this watcher from the system if it
has expired.
|
private final long timestamp
private final long tiebreaker
final long startOrdinal
private static final java.util.concurrent.atomic.AtomicLong nextTiebreaker
TransitionWatcher(long timestamp,
long startOrdinal)
TransitionWatcher.timestamp - the value that is used
to sort TransitionWatchers.startOrdinal - the highest ordinal associated
with operations that are considered to have occurred
before the operation associated with this watcher.abstract boolean addTemplateHandle(TemplateHandle h)
TemplateHandle with this object. An
implementation may support calling this method only once on
a given instance.h - The TemplateHandle associated
with this watcher.true if the handle was succfully added,
and false if the watcher has already
been removed.NullPointerException - if h is
nullpublic int compareTo(TransitionWatcher o)
TransitionWatcher a
ClassCastException will be thrown. The object with
the lower time stamp will be considered less than the other. If they
both have the same time stamp the object will the lower
tie breaker will be less than the other. If both have the same
tie breaker and time stamp they will be considered equal.
This method may be called before addTemplateHandle
is called.
compareTo in interface Comparable<TransitionWatcher>ClassCastException - if o is not
a TransitionWatcher.public abstract long getExpiration()
addTemplateHandle is called.
Assumes locking is handled by the caller.abstract void removeIfExpired(long now)
remove method
of the associated TemplateHandle.
This method can be called more than once,
though second and subsequent calls may have no effect.now - An estimate of the current time that must be
less than or equal to the current time.abstract boolean isInterested(EntryTransition transition, long ordinal)
true if this watcher cares about a given
visibility transition. Assumes the transitioning entry matches
the template in the TemplateHandle associated with
this watcher. This method should return a value even if the
expiration time has been reached or remove has
been called. This call should not obtain any locks.transition - A EntryTransition that
describes the transition and what
entry is transitioning. This method
will assume that transition.getHandle
returns a non-null value.ordinal - The ordinal associated with transition.true if this watcher is interested
in the indicated transition and false
otherwise.NullPointerException - if transition is
null.abstract void process(EntryTransition transition, long now)
TemplateHandle associated with this
watcher and that isInterested returned
true. This call may make changes to the passed
EntryHandle that will prevent it from being used by
other watchers. If remove has been called or the
expiration time of this watcher has passed, this call should have no
effect. This call may cause the watcher to be removed.transition - A EntryTransition that
describes the transition and what
entry is transitioning. This method
will assume that transition.getHandle
returns a non-null value.now - An estimate of the current time (not the time
when the event occured).NullPointerException - if transition is
null.Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.