ReplacementPolicy.Callback
private class ClockPolicy.Holder extends java.lang.Object implements ReplacementPolicy.Callback
recentlyUsed
required by the clock algorithm. The class
also implements the Callback
interface, so that
ConcurrentCache
can notify the clock policy about events
relevant to the clock algorithm.Modifier and Type | Field | Description |
---|---|---|
private CacheEntry |
entry |
Reference to the
CacheEntry object held by this
object. |
private boolean |
evicted |
Flag which tells whether this holder has been evicted from the
clock.
|
private Cacheable |
freedCacheable |
Cacheable object from a removed object.
|
(package private) boolean |
recentlyUsed |
Flag indicating whether or not this entry has been accessed
recently.
|
Constructor | Description |
---|---|
Holder(CacheEntry e) |
Modifier and Type | Method | Description |
---|---|---|
void |
access() |
Mark this entry as recently used.
|
(package private) boolean |
evictIfFree() |
Evict this holder from the clock if it is not associated with an
entry.
|
void |
free() |
Mark this object as free and reusable.
|
(package private) CacheEntry |
getEntry() |
Returns the entry that is currently associated with this holder.
|
(package private) boolean |
isEvicted() |
Check whether this holder has been evicted from the clock.
|
(package private) void |
setEvicted() |
Mark this holder as evicted from the clock, effectively preventing
reuse of the holder.
|
(package private) void |
switchEntry(CacheEntry e) |
Switch which entry the holder is associated with.
|
(package private) boolean |
takeIfFree(CacheEntry e) |
Associate this holder with the specified entry if the holder is free
(that is, not associated with any other entry).
|
boolean recentlyUsed
CacheEntry
object stored in the
entry
field.private CacheEntry entry
CacheEntry
object held by this
object. The reference should only be accessed when the thread owns
the monitor on this holder. A thread is only allowed to change the
reference if it also has locked the entry that the reference points
to (if the reference is non-null). This ensures that no other thread
can disassociate a holder from its entry while the entry is locked,
even though the monitor on the holder has been released.private Cacheable freedCacheable
entry
must be null
(which means that the
holder is not associated with any object in the cache).private boolean evicted
Holder(CacheEntry e)
public void access()
entry
.access
in interface ReplacementPolicy.Callback
public void free()
entry
.free
in interface ReplacementPolicy.Callback
boolean takeIfFree(CacheEntry e)
e
- the entry to associate the holder with (it must be locked
by the current thread)true
if the holder has been associated with the
specified entry, false
if someone else has taken it or
the holder has been evicted from the clockCacheEntry getEntry()
void switchEntry(CacheEntry e)
e
- the entry to associate this holder withboolean evictIfFree()
true
if the holder was successfully evicted,
false
otherwisevoid setEvicted()
boolean isEvicted()
true
if it has been evicted, false
otherwiseApache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.