class TemplateHandle extends BaseHandle
TemplateHandle
associates one or more
TransitionWatcher
s with a template.
Unless otherwise noted all methods are thread safe.Modifier and Type | Field and Description |
---|---|
private Vector |
descs
A cache of the
EntryHandleTmplDesc indexed
by the number of fields. |
private WatchersForTemplateClass |
owner
The
WatchersForTemplateClass this object
belongs to. |
private Set |
watchers
The watchers.
|
Constructor and Description |
---|
TemplateHandle(EntryRep tmpl,
WatchersForTemplateClass owner)
Create a handle for the template
tmpl . |
Modifier and Type | Method and Description |
---|---|
(package private) void |
addTransitionWatcher(TransitionWatcher watcher)
Add a watcher to this handle.
|
(package private) void |
collectInterested(Set 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 numFields)
Return the description for the given field count.
|
(package private) OutriggerServerImpl |
getServer()
Return the
OutriggerServerImpl this
handle is part of. |
(package private) boolean |
isEmpty()
Return
true if there are no watchers associated
with this object and false otherwise. |
(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. |
(package private) void |
removeTransitionWatcher(TransitionWatcher watcher)
Remote a watcher from this handle.
|
classFor, rep
getIndex, getList, markOnList, remove, removed, setIndex, setList
private final Vector descs
EntryHandleTmplDesc
indexed
by the number of fields.private final Set 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 WatchersForTemplateClass owner
WatchersForTemplateClass
this object
belongs to.TemplateHandle(EntryRep tmpl, WatchersForTemplateClass owner)
tmpl
.EntryHandleTmplDesc descFor(int numFields)
boolean matches(EntryRep entry)
true
if this template matches the given entry.void addTransitionWatcher(TransitionWatcher watcher)
FastList
and that
the caller owns the lock on this
.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 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 isEmpty()
true
if there are no watchers associated
with this object and false
otherwise. Assumes
the call holds the lock on this
.true
if there are no watchers in this handle.Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.