class TemplateHandle extends BaseHandle
TemplateHandle associates one or more
TransitionWatchers with a template.
Unless otherwise noted all methods are thread safe.| Modifier and Type | Field and Description |
|---|---|
private OutriggerServerImpl |
owner
The
WatchersForTemplateClass this object
belongs to. |
private boolean |
removed |
private java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock |
rl |
private Set<TransitionWatcher> |
watchers
The watchers.
|
private java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock |
wl
WriteLock guarantees that no updates can be performed during a
removal operation.
|
| Constructor and Description |
|---|
TemplateHandle(EntryRep tmpl,
OutriggerServerImpl owner,
Queue<TemplateHandle> content)
Create a handle for the template
tmpl. |
| Modifier and Type | Method and Description |
|---|---|
(package private) boolean |
addTransitionWatcher(TransitionWatcher watcher)
Add a watcher to this handle.
|
(package private) void |
collectInterested(Set<TransitionWatcher> set,
EntryTransition transition,
long ordinal)
Iterate over the watchers associated with
this handle calling
isInterested on each
and if it returns true adding the watcher to the
passed set. |
(package private) EntryHandleTmplDesc |
descFor(int index)
Return the description for the given field count.
|
(package private) OutriggerServerImpl |
getServer()
Return the
OutriggerServerImpl this
handle is part of. |
(package private) boolean |
matches(EntryRep entry)
Return
true if this template matches the given entry. |
(package private) void |
reap(long now)
Visit each
TransitionWatcher and check to see if
it has expired, removing it if it has. |
boolean |
remove()
Overridden and called from subclass.
|
boolean |
removed() |
(package private) boolean |
removeIfEmpty()
Need to lock on the wl so no one will
add a watcher between the check for empty and
when it gets removed.
|
(package private) void |
removeTransitionWatcher(TransitionWatcher watcher)
Remote a watcher from this handle.
|
classFor, repprivate final Set<TransitionWatcher> watchers
HashSet because we will
probably do a fair number of removals for each traversal and
the number of watchers managed by one TemplateHandle
will probably never get very large. If this does become an
issue making TransitionWatcher extend
FastList.Node and using a FastList
here would probably be a good choice (though that would require
changing FastList to support overlapping traversals
of different lists from the same thread.)private final java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock wl
private final java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock rl
private boolean removed
private final OutriggerServerImpl owner
WatchersForTemplateClass this object
belongs to.TemplateHandle(EntryRep tmpl, OutriggerServerImpl owner, Queue<TemplateHandle> content)
tmpl.EntryHandleTmplDesc descFor(int index)
boolean matches(EntryRep entry)
true if this template matches the given entry.boolean addTransitionWatcher(TransitionWatcher watcher)
watcher - the watcher to be added.NullPointerException - if watcher is null.void removeTransitionWatcher(TransitionWatcher watcher)
TemplateHandle.watcher - the watcher to be removed.NullPointerException - if watcher is null.void collectInterested(Set<TransitionWatcher> set, EntryTransition transition, long ordinal)
isInterested on each
and if it returns true adding the watcher to the
passed set.set - The set to accumulate interested watchers
into.transition - The transition being processed.ordinal - The ordinal associated with transition.NullPointerException - if either argument is null.OutriggerServerImpl getServer()
OutriggerServerImpl this
handle is part of.OutriggerServerImpl this
handle is part of.void reap(long now)
TransitionWatcher and check to see if
it has expired, removing it if it has.now - an estimate of the current time expressed as
milliseconds since the beginning of the epoch.boolean removeIfEmpty()
public boolean removed()
removed in class BaseHandlepublic boolean remove()
BaseHandleremove in class BaseHandleCopyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.