Class SimpleOverflowMap.Status
- Enclosing class:
- SimpleOverflowMap
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected static final intBitmask for entry in front.protected static final intBitmask for value in front and back being in sync.protected static final intBitmask for fields that would indicate that the Status must not be discarded.protected static final intBitmask for status (least significant three bits reserved).protected static final intBit values for fields that would indicate that the Status can be discarded.protected static final intStatus: The Status object exists and no thread is currently performing processing against the associated entry.protected static final intStatus: The Status object represents an Entry that was very recently being processed, and is currently finalizing the results of that processing.protected static final intStatus: The Status object has been discarded.protected static final intStatus: The Status object represents an Entry that is currently being processed.protected static final intStatus: The Status object has been reserved for processing by a thread but is not yet processing.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionFinish the processing of the entry for which this Status exists and proceed to the commit phase.protected booleanFinish the commit for the entry for which this Status exists.protected booleanextractFlag(int nMask) Extract a particular masked flag from the state of the Status object.protected intextractState(int nMask) Extract a particular masked value from the state of the Status object.Assemble a human-readable description.protected MapEventFor internal use only, return the current event from the front Map.Determine the thread that owns the Status object, if the Status object is processing or committing.protected intgetState()Determine the state of the Status object.protected intDetermine the enumerated status of the Status object.booleanhasEvent()Determine if an event has occurred against the Entry for which this Status exists.booleanDetermine if the Status object is available.booleanDetermine if the entry for which this Status exists has the same value in the front Map as in the back Map.booleanDetermine if the Status object represents an Entry that has been processed and the results of that processing are being committed.protected booleanDetermine if this Status object can be discarded.booleanDetermine if the entry for which this Status exists is present in the front map.booleanDetermine if the current thread owns this Status object.booleanDetermine if the Status object represents an Entry that is currently being processed.booleanDetermine if the Status object is reserved.booleanisValid()Determine if the Status object is valid.protected MapEventmergeEvents(MapEvent evtOld, MapEvent evtNew) Merge two events that have been raised in sequence from a given map.booleanRegister a MapEvent that has been raised by the front Map against the same key for which this Status object exists.protected booleanAttempt to reserve the Status by marking it as committing if it is available.voidsetBackUpToDate(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).voidsetEntryInFront(boolean fEntryInFront) Specify whether the entry for which this Status exists is present in the front map.protected voidsetFrontEvent(MapEvent evt) For internal use only, store the current event from the front Map.protected voidsetOwnerThread(Thread thread) Specify the thread that owns the Status object.protected voidsetState(int nState) Specify the state of the Status object.protected voidsetStatus(int nStatus) Determine the enumerated state of the Status object.Obtain the most recent front Map event that has occurred against the Entry for which this Status exists.toString()Returns a string representation of the object.protected voidupdateFlag(int nMask, boolean f) Update a particular masked flag within the state of the Status object.protected voidupdateState(int nMask, int nValue) Update a particular masked value within the state of the Status object.protected MapEventAfter having successfully made a reservation, this method completes the reservation process by setting the status to processing for the thread that made the reservation.protected MapEventWait for the Entry that this Status represents to become available.protected voidWait for the Entry that this Status represents to no longer be reserved.
- 
Field Details- 
STATE_MASK_STATUSprotected static final int STATE_MASK_STATUSBitmask for status (least significant three bits reserved).- See Also:
 
- 
STATE_MASK_FRONTprotected static final int STATE_MASK_FRONTBitmask for entry in front.- See Also:
 
- 
STATE_MASK_INSYNCprotected static final int STATE_MASK_INSYNCBitmask for value in front and back being in sync.- See Also:
 
- 
STATUS_AVAILABLEprotected static final int STATUS_AVAILABLEStatus: The Status object exists and no thread is currently performing processing against the associated entry.- See Also:
 
- 
STATUS_RESERVEDprotected static final int STATUS_RESERVEDStatus: The Status object has been reserved for processing by a thread but is not yet processing.- See Also:
 
- 
STATUS_PROCESSINGprotected static final int STATUS_PROCESSINGStatus: The Status object represents an Entry that is currently being processed.- See Also:
 
- 
STATUS_COMMITTINGprotected static final int STATUS_COMMITTINGStatus: The Status object represents an Entry that was very recently being processed, and is currently finalizing the results of that processing.- See Also:
 
- 
STATUS_INVALIDATEDprotected static final int STATUS_INVALIDATEDStatus: The Status object has been discarded.- See Also:
 
- 
STATE_MASK_RETAINprotected static final int STATE_MASK_RETAINBitmask for fields that would indicate that the Status must not be discarded.- See Also:
 
- 
STATE_VALUE_RETAINprotected static final int STATE_VALUE_RETAINBit values for fields that would indicate that the Status can be discarded.- See Also:
 
 
- 
- 
Constructor Details- 
Statuspublic Status()Construct a Status object for a specific key.
 
- 
- 
Method Details- 
getStatusprotected int getStatus()Determine the enumerated status of the Status object. This value is intended for internal and debugging use only, and should have no meaning to any external consumer.- Returns:
- a number corresponding to the enumeration of states as represented by the STATUS_*
 
- 
setStatusprotected void setStatus(int nStatus) Determine the enumerated state of the Status object. This value is intended for internal and debugging use only, and should have no meaning to any external consumer.- Parameters:
- nStatus- a number corresponding to one of the enumeration represented by the STATUS_* constants
 
- 
isValidpublic boolean isValid()Determine if the Status object is valid. A Status object can be discarded (no longer used), in which case it will not be valid.- Returns:
- true iff the Status object is still valid
 
- 
isAvailablepublic boolean isAvailable()Determine if the Status object is available. A Status object is available if it is valid and no thread is currently processing the entry for which this Status object exists.- Returns:
- true iff the Status object is available
 
- 
isReservedpublic boolean isReserved()Determine if the Status object is reserved.- Returns:
- true iff the Status object is available
 
- 
isProcessingpublic boolean isProcessing()Determine if the Status object represents an Entry that is currently being processed.- Returns:
- true iff the entry represented by this Status object is being processed
 
- 
isCommittingpublic boolean isCommitting()Determine if the Status object represents an Entry that has been processed and the results of that processing are being committed. The "committing" status implies that no other thread is allowed to do anything related to the entry that this Status represents.- Returns:
- true iff the entry represented by this Status object is being committed
 
- 
getOwnerThreadDetermine the thread that owns the Status object, if the Status object is processing or committing.- Returns:
- the owning thread, or null
 
- 
setOwnerThreadSpecify the thread that owns the Status object. For internal use only.- Parameters:
- thread- the owning thread, or null
 
- 
isOwnedByCurrentThreadpublic boolean isOwnedByCurrentThread()Determine if the current thread owns this Status object.- Returns:
- true iff the current thread owns this Status object
 
- 
isEntryInFrontpublic boolean isEntryInFront()Determine if the entry for which this Status exists is present in the front map.- Returns:
- true iff the entry is stored in the front map
 
- 
setEntryInFrontpublic void setEntryInFront(boolean fEntryInFront) Specify whether the entry for which this Status exists is present in the front map.- Parameters:
- fEntryInFront- pass true if the entry is stored in the front map, false if not
 
- 
isBackUpToDatepublic boolean isBackUpToDate()Determine if the entry for which this Status exists has the same value in the front Map as in the back Map.- Returns:
- true iff the value exists in the back Map, and the value in the front Map is the same as the value in the back Map
 
- 
setBackUpToDatepublic 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).- Parameters:
- fUpToDate- whether the stored value is up to date
 
- 
getFrontEventFor internal use only, return the current event from the front Map. All handling of synchronization etc. is the responsibility of the sub-class.- Returns:
- the cummulative front Map event for the Entry represented by this Status object, or null if there were no events
 
- 
setFrontEventFor internal use only, store the current event from the front Map. All handling of synchronization etc. is the responsibility of the sub-class.- Parameters:
- evt- the cummulative front Map event for the Entry represented by this Status object, or null to clear the event
 
- 
hasEventpublic boolean hasEvent()Determine if an event has occurred against the Entry for which this Status exists.- Returns:
- true iff an event is held by the Status
 
- 
takeEventObtain the most recent front Map event that has occurred against the Entry for which this Status exists.- Returns:
- the cummulative front Map event for the Entry represented by this Status object, or null if there were no events
 
- 
isDiscardableprotected boolean isDiscardable()Determine if this Status object can be discarded.This is an internal method. - Returns:
- true iff this Status object can be discarded
 
- 
getDescriptionAssemble a human-readable description.- Returns:
- a description of this Status object
 
- 
toStringReturns a string representation of the object.
- 
waitForAvailableWait for the Entry that this Status represents to become available. Once it becomes available, the current thread will automatically become the owner and the status will be changed to "processing".This is an internal method. It requires the caller to have synchronized on the Status object before calling this method. - Returns:
- whatever event was deferred for this Status which the caller must handle
 
- 
requestReservationprotected boolean requestReservation()Attempt to reserve the Status by marking it as committing if it is available. If successful, the caller must subsequently either calluseReservation()orcommitAndMaybeInvalidate()(to cancel the reservation).This is an internal method. - Returns:
- true if the reservation was made successfull, false if another thread already owns this Status object
 
- 
waitForReservationDecisionprotected void waitForReservationDecision()Wait for the Entry that this Status represents to no longer be reserved.This is an internal method. It requires the caller to have synchronized on the Status object before calling this method. 
- 
useReservationAfter having successfully made a reservation, this method completes the reservation process by setting the status to processing for the thread that made the reservation.This is an internal method. - Returns:
- whatever event was deferred for this Status which the caller must handle
 
- 
closeProcessingFinish the processing of the entry for which this Status exists and proceed to the commit phase. The act of closing processing collects any side-effects to the corresponding front Map Entry (either from this or other threads) as a single event.- Returns:
- all events that have occurred on this or other threads for the front Map Entry represented by this Status object while this Status object was "processing", or null if there were no events
 
- 
commitAndMaybeInvalidateprotected boolean commitAndMaybeInvalidate()Finish the commit for the entry for which this Status exists. If there are any threads waiting on the entry for which this Status exists, one will be notified that the Status is now available. If the entry for which this Status object exists is contained in the front Map, then it will proceed to the available phase. Otherwise, the Status will be invalidated and discarded from the Status registry.This is an internal method. It requires the caller to have first synchronized on the registry (Map) that contains the Status objects and then to have synchronized on this Status object itself, in that explicit order. Failure to follow this rule will result in deadlock and/or exceptional conditions. - Returns:
- true iff this Status object has invalidated itself
 
- 
registerFrontEventRegister a MapEvent that has been raised by the front Map against the same key for which this Status object exists. If an event has previously been registered, the previous and new event are merged into a single merged event that incorporates the data from both events.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 - Parameters:
- evt- the event that has occurred against an entry in the front Map with the same key which this Status object represents
- Returns:
- true iff the event processing has been deferred, implying that this Status object should be registered in a list of Status objects that have events that need to be handled
 
- 
mergeEventsMerge two events that have been raised in sequence from a given map.- Parameters:
- evtOld- the first event
- evtNew- the second event
- Returns:
- the merged event
 
- 
getStateprotected int getState()Determine the state of the Status object. This value is intended for internal and debugging use only, and should have no meaning to any external consumer.- Returns:
- the bit-packed state of the Status object
 
- 
setStateprotected void setState(int nState) Specify the state of the Status object. This value is intended for internal and debugging use only, and should have no meaning to any external consumer.- Parameters:
- nState- the new bit-packed state for the Status object
 
- 
extractStateprotected int extractState(int nMask) Extract a particular masked value from the state of the Status object.- Parameters:
- nMask- the mask identifying the value
- Returns:
- the extracted value
 
- 
updateStateprotected void updateState(int nMask, int nValue) Update a particular masked value within the state of the Status object.- Parameters:
- nMask- the mask of bits to store the value within
- nValue- the value to store inside that mask
 
- 
extractFlagprotected boolean extractFlag(int nMask) Extract a particular masked flag from the state of the Status object.- Parameters:
- nMask- the mask identifying the flag
- Returns:
- the extracted flag as a boolean
 
- 
updateFlagprotected void updateFlag(int nMask, boolean f) Update a particular masked flag within the state of the Status object.- Parameters:
- nMask- the mask of flag bit to store the flag within
- f- the boolean value to store within that mask
 
 
-