protected static class OverflowMap.Status extends Object
Modifier and Type | Field and Description |
---|---|
protected static int |
STATE_MASK_BACK
Bitmask for entry in back.
|
protected static int |
STATE_MASK_EXISTS
Bitmask for fields that would indicate that the Status represents
an existent entry in the OverflowMap.
|
protected static int |
STATE_MASK_FRONT
Bitmask for entry in front.
|
protected static int |
STATE_MASK_INSYNC
Bitmask for value in front and back being in sync.
|
protected static int |
STATE_MASK_RETAIN
Bitmask for fields that would indicate that the Status must not be
discarded.
|
protected static int |
STATE_MASK_STATUS
Bitmask for status (least significant three bits reserved).
|
protected static int |
STATUS_AVAILABLE
Status: The Status object exists and no thread is currently
performing processing against the associated entry.
|
protected static int |
STATUS_COMMITTING
Status: The Status object represents an Entry that was very
recently being processed, and is currently finalizing the results
of that processing.
|
protected static int |
STATUS_INVALIDATED
Status: The Status object has been discarded.
|
protected static int |
STATUS_PROCESSING
Status: The Status object represents an Entry that is currently
being processed.
|
Constructor and Description |
---|
Status()
Construct a Status object.
|
Modifier and Type | Method and Description |
---|---|
MapEvent |
closeProcessing()
Finish the processing of the entry for which this Status exists and
proceed to the commit phase.
|
protected boolean |
commitAndMaybeInvalidate()
Finish the commit for the entry for which this Status exists.
|
protected boolean |
extractFlag(int nMask)
Extract a particular masked flag from the state of the Status
object.
|
protected int |
extractState(int nMask)
Extract a particular masked value from the state of the Status
object.
|
protected MapEvent |
getBackEvent()
For internal use only, return the current event from the back
Map.
|
String |
getDescription()
Assemble a human-readable description.
|
long |
getExpiry()
Determine the expiry for the entry represented by this Status.
|
protected MapEvent |
getFrontEvent()
For internal use only, return the current event from the front
Map.
|
Thread |
getOwnerThread()
Determine the thread that owns the Status object, if the Status
object is processing or committing.
|
protected int |
getState()
Determine the state of the Status object.
|
protected int |
getStatus()
Determine the enumerated status of the Status object.
|
boolean |
hasEvent()
Determine if an event has occurred against the Entry for which this
Status exists.
|
boolean |
hasExpiry()
Determine if this Status represents an entry that will
automatically expire.
|
boolean |
isAvailable()
Determine if the Status object is available.
|
boolean |
isBackUpToDate()
Determine if the entry for which this Status exists has the same
value in the front Map as in the back Map.
|
boolean |
isCommitting()
Determine if the Status object represents an Entry that has been
processed and the results of that processing are being committed.
|
protected boolean |
isDiscardable()
Determine if this Status object can be discarded.
|
boolean |
isEntryExistent()
Determine if the entry for which this Status exists is present in
the front map or the back map.
|
boolean |
isEntryInBack()
Determine if the entry for which this Status exists is present in
the back map.
|
boolean |
isEntryInFront()
Determine if the entry for which this Status exists is present in
the front map.
|
boolean |
isExpired()
Determine if this Status represents an entry that will
automatically expire.
|
boolean |
isOwnedByCurrentThread()
Determine if the current thread owns this Status object.
|
boolean |
isProcessing()
Determine if the Status object represents an Entry that is
currently being processed.
|
boolean |
isValid()
Determine if the Status object is valid.
|
boolean |
registerBackEvent(MapEvent evt)
Register a MapEvent that has been raised by the back Map against
the same key for which this Status object exists.
|
boolean |
registerFrontEvent(MapEvent evt)
Register a MapEvent that has been raised by the front Map against
the same key for which this Status object exists.
|
protected void |
setBackEvent(MapEvent evt)
For internal use only, store the current event from the back Map.
|
void |
setBackUpToDate(boolean fUpToDate)
Specify that the value stored in the back Map is known to be up to
date (not needing to be written to the back if evicted from the
front).
|
void |
setEntryInBack(boolean fEntryInBack)
Specify whether the entry for which this Status exists is present
in the back map.
|
void |
setEntryInFront(boolean fEntryInFront)
Specify whether the entry for which this Status exists is present
in the front map.
|
void |
setExpiry(long ldtExpires)
Specify the expiry for the entry represented by this Status.
|
protected void |
setFrontEvent(MapEvent evt)
For internal use only, store the current event from the front Map.
|
protected void |
setOwnerThread(Thread thread)
Specify the thread that owns the Status object.
|
protected void |
setState(int nState)
Specify the state of the Status object.
|
protected void |
setStatus(int nStatus)
Determine the enumerated state of the Status object.
|
MapEvent |
takeBackEvent()
Obtain the most recent back Map event that has occurred against
the Entry for which this Status exists.
|
MapEvent |
takeEvent()
Obtain the most recent event that has occurred against the Entry
for which this Status exists.
|
MapEvent |
takeFrontEvent()
Obtain the most recent front Map event that has occurred against
the Entry for which this Status exists.
|
String |
toString()
Returns a string representation of the object.
|
protected void |
updateFlag(int nMask,
boolean f)
Update a particular masked flag within the state of the Status
object.
|
protected void |
updateState(int nMask,
int nValue)
Update a particular masked value within the state of the Status
object.
|
protected MapEvent |
waitForAvailable()
Wait for the Entry that this Status represents to become available.
|
protected static final int STATE_MASK_STATUS
protected static final int STATE_MASK_FRONT
protected static final int STATE_MASK_BACK
protected static final int STATE_MASK_INSYNC
protected static final int STATE_MASK_EXISTS
protected static final int STATE_MASK_RETAIN
protected static final int STATUS_AVAILABLE
protected static final int STATUS_PROCESSING
protected static final int STATUS_COMMITTING
protected static final int STATUS_INVALIDATED
protected int getStatus()
protected void setStatus(int nStatus)
nStatus
- a number corresponding to one of the enumeration
represented by the STATUS_* constantspublic boolean isValid()
public boolean isAvailable()
public boolean isProcessing()
public boolean isCommitting()
public Thread getOwnerThread()
protected void setOwnerThread(Thread thread)
thread
- the owning thread, or nullpublic boolean isOwnedByCurrentThread()
public boolean isEntryInFront()
public void setEntryInFront(boolean fEntryInFront)
fEntryInFront
- pass true if the entry is stored in the front
map, false if notpublic boolean isEntryInBack()
public void setEntryInBack(boolean fEntryInBack)
fEntryInBack
- pass true if the entry is stored in the back
map, false if notpublic boolean isEntryExistent()
public boolean isBackUpToDate()
public void setBackUpToDate(boolean fUpToDate)
fUpToDate
- the flag indicate back up to dateprotected MapEvent getFrontEvent()
protected void setFrontEvent(MapEvent evt)
evt
- the cummulative front Map event for the Entry
represented by this Status object, or null to clear
the eventprotected MapEvent getBackEvent()
protected void setBackEvent(MapEvent evt)
evt
- the cummulative back Map event for the Entry
represented by this Status object, or null to clear
the eventpublic boolean hasEvent()
public MapEvent takeFrontEvent()
public MapEvent takeBackEvent()
public MapEvent takeEvent()
public long getExpiry()
public void setExpiry(long ldtExpires)
ldtExpires
- the expiry, or 0L if the entry should not expirepublic boolean hasExpiry()
public boolean isExpired()
protected boolean isDiscardable()
This is an internal method.
public String getDescription()
public String toString()
protected MapEvent waitForAvailable()
public MapEvent closeProcessing()
protected boolean commitAndMaybeInvalidate()
This is an internal method. It requires the caller to have first synchronized on the registry (Map) that contains the Status objects before calling this method (or otherwise synchronizing on this Status object). Failure to follow this rule will result in deadlock and/or exceptional conditions.
public boolean registerFrontEvent(MapEvent evt)
For truly predictable behavior, this requires that the front Map implementation be synchronized during the raising of events, such that an event will only be raised from the front Map on one thread at a time. The event listener (for the overflow map) must then synchronize on this Status object (to verify that it is indeed valid before registering the event) and the register the event while holding that synchronization. If the registration returns a deferred indicator, then the
evt
- the event that has occurred against an entry in the
front Map with the same key which this Status object
representspublic boolean registerBackEvent(MapEvent evt)
evt
- the event that has occurred against an entry in the
back Map with the same key which this Status object
representsprotected int getState()
protected void setState(int nState)
nState
- the new bit-packed state for the Status objectprotected int extractState(int nMask)
nMask
- the mask identifying the valueprotected void updateState(int nMask, int nValue)
nMask
- the mask of bits to store the value withinnValue
- the value to store inside that maskprotected boolean extractFlag(int nMask)
nMask
- the mask identifying the flagprotected void updateFlag(int nMask, boolean f)
nMask
- the mask of flag bit to store the flag withinf
- the boolean value to store within that mask