com.opensymphony.oscache.base
Class EntryUpdateState

java.lang.Object
  extended bycom.opensymphony.oscache.base.EntryUpdateState

public class EntryUpdateState
extends Object

Holds the state of a Cache Entry that is in the process of being (re)generated. This is not synchronized; the synchronization must be handled by the calling classes.

Version:
Revision: $
Author:
Chris Miller, Author: $

Field Summary
static int NOT_YET_UPDATING
          The initial state when this object is first created
static int UPDATE_CANCELLED
          Update cancelled state
static int UPDATE_COMPLETE
          Update complete state
static int UPDATE_IN_PROGRESS
          Update in progress state
 
Constructor Summary
EntryUpdateState()
           
 
Method Summary
 int cancelUpdate()
          Updates the state to UPDATE_CANCELLED.
 int completeUpdate()
          Updates the state to UPDATE_COMPLETE.
 int decrementUsageCounter()
          Decrements the usage counter by one.
 int getUsageCounter()
          Gets the current usage counter value
 int incrementUsageCounter()
          Increments the usage counter by one
 boolean isAwaitingUpdate()
          This is the initial state when an instance this object is first created.
 boolean isCancelled()
          The thread that was responsible for updating the cache entry (ie, the thread that managed to grab the update lock) has decided to give up responsibility for performing the update.
 boolean isComplete()
          The update of the cache entry has been completed.
 boolean isUpdating()
          The cache entry is currently being generated by the thread that got hold of the update lock.
 int startUpdate()
          Attempt to change the state to UPDATE_IN_PROGRESS.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_YET_UPDATING

public static final int NOT_YET_UPDATING
The initial state when this object is first created

See Also:
Constant Field Values

UPDATE_IN_PROGRESS

public static final int UPDATE_IN_PROGRESS
Update in progress state

See Also:
Constant Field Values

UPDATE_COMPLETE

public static final int UPDATE_COMPLETE
Update complete state

See Also:
Constant Field Values

UPDATE_CANCELLED

public static final int UPDATE_CANCELLED
Update cancelled state

See Also:
Constant Field Values
Constructor Detail

EntryUpdateState

public EntryUpdateState()
Method Detail

isAwaitingUpdate

public boolean isAwaitingUpdate()
This is the initial state when an instance this object is first created. It indicates that a cache entry needs updating, but no thread has claimed responsibility for updating it yet.


isCancelled

public boolean isCancelled()
The thread that was responsible for updating the cache entry (ie, the thread that managed to grab the update lock) has decided to give up responsibility for performing the update. OSCache will notify any other threads that are waiting on the update so one of them can take over the responsibility.


isComplete

public boolean isComplete()
The update of the cache entry has been completed.


isUpdating

public boolean isUpdating()
The cache entry is currently being generated by the thread that got hold of the update lock.


cancelUpdate

public int cancelUpdate()
Updates the state to UPDATE_CANCELLED. This should only be called by the thread that managed to get the update lock.

Returns:
the counter value after the operation completed

completeUpdate

public int completeUpdate()
Updates the state to UPDATE_COMPLETE. This should only be called by the thread that managed to get the update lock.

Returns:
the counter value after the operation completed

startUpdate

public int startUpdate()
Attempt to change the state to UPDATE_IN_PROGRESS. Calls to this method must be synchronized on the EntryUpdateState instance.

Returns:
the counter value after the operation completed

incrementUsageCounter

public int incrementUsageCounter()
Increments the usage counter by one

Returns:
the counter value after the increment

getUsageCounter

public int getUsageCounter()
Gets the current usage counter value

Returns:
a positive number.

decrementUsageCounter

public int decrementUsageCounter()
Decrements the usage counter by one. This method may only be called when the usage number is greater than zero

Returns:
the counter value after the decrement

OSCache Project Page