|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.ksu.cis.projects.bogor.module.value.DefaultLockValue
public class DefaultLockValue
The default implementation of ILockValue.
| Field Summary | |
|---|---|
protected int |
lockCounter
Holds the lock counter of this lock value's owner. |
protected IntSet |
notification
Holds the notification set of this lock value. |
protected int |
owner
Holds the owner id of this lock value. |
protected int |
referenceId
Holds the reference id of this lock. |
protected LockType |
type
Holds the lock type of this lock value. |
protected IValueFactory |
vf
Holds the value factory of this lock value. |
protected IntSet |
waiting
Holds the wait set of this lock value. |
| Constructor Summary | |
|---|---|
protected |
DefaultLockValue()
Private constructor for cloning purposes. |
protected |
DefaultLockValue(IValueFactory vf,
int referenceId,
LockType type,
IntSet waiting,
IntSet notification)
Default constructor. |
| Method Summary | |
|---|---|
ILockValue |
clone(Map<Object,Object> cloneMap)
Override to specialize return type |
int |
compareTo(IValue o)
|
void |
dispose()
Remove references. |
boolean |
equals(Object o)
Classes implementing IValue should provide their own
equality tests. |
int |
getLockCounter()
Gets the lock counter of the owner of this lock. |
IntSet |
getNotification()
Gets the notification set of this lock value. |
int |
getOwner()
Gets the thread id who hold this lock. |
int |
getReferenceId()
Gets this non-primitive value reference id. |
Type |
getType()
Gets the type of this value. |
int |
getTypeId()
Gets the type id of this value. |
IntSet |
getWaiting()
Gets the wait set of this lock value. |
int |
hashCode()
Classes implementing IValue should provide their own
hashing method. |
byte[][] |
linearize(int bitsPerNonPrimitiveValue,
ObjectIntTable nonPrimitiveValueIdMap,
int bitsPerThreadId,
IntIntTable threadOrderMap)
Linearizes this lock value. |
void |
opLock(int threadId)
Does a lock operation on this lock value. |
void |
opNotify(int threadId,
int nextThreadId)
Does a notify operation on this lock value. |
void |
opNotifyAll(int threadId)
Does a notify all operation on this lock value. |
void |
opUnlock(int threadId)
Does an unlock operation on this lock. |
void |
opUnwait(int threadId,
int i)
Does an unwait operation on this lock value. |
int |
opWait(int threadId)
Does a wait operation on this lock value. |
void |
setLockCounter(int lockCounter)
Sets the lock counter of the owner of this lock. |
void |
setOwner(int threadId)
Sets the thread id who holds this lock. |
boolean |
testHasLock(int threadId)
Tests whether a particular thread holds this lock value. |
boolean |
testLockAvailable(int threadId)
Tests whether this lock value is available to do operation on by a particular thread. |
boolean |
testWasNotified(int threadId)
Tests whether a particular thread was notified in this lock value. |
String |
toString()
Gets the string representation of this value. |
void |
undoOp(LockOp lockOp,
int owner,
int lockCounter,
int[] notification,
int[] waiting,
int notifiedThreadId)
Undo a lock op. |
void |
validate(IBogorConfiguration bc)
Freshen references to Bogor model checking components and other non-serializable objects. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected transient IValueFactory vf
protected IntSet notification
protected IntSet waiting
protected int lockCounter
protected int owner
IStateFactory.EPSILON_THREAD, if free.
protected LockType type
protected int referenceId
| Constructor Detail |
|---|
protected DefaultLockValue(IValueFactory vf,
int referenceId,
LockType type,
IntSet waiting,
IntSet notification)
vf - The value factory of this lock value. Must be non-null.referenceId - The reference id for this lock value. Must be greater than 0.type - The lock type for this lock value. Must be non-null.waiting - The wait set for this lock value. Must be non-null.notification - The notification set for this lock value. Must be non-null.protected DefaultLockValue()
| Method Detail |
|---|
public void setLockCounter(int lockCounter)
ILockValue
setLockCounter in interface ILockValuelockCounter - The lock counter if this lock is held.public int getLockCounter()
ILockValue
getLockCounter in interface ILockValuepublic IntSet getNotification()
ILockValue
getNotification in interface ILockValuepublic void setOwner(int threadId)
ILockValue
setOwner in interface ILockValuethreadId - The thread id who holds this lock.public int getOwner()
ILockValue
getOwner in interface ILockValuepublic int getReferenceId()
INonPrimitiveValue
getReferenceId in interface INonPrimitiveValuepublic Type getType()
IValue
getType in interface IValueType.getTypeId()public int getTypeId()
IValue
getTypeId in interface IValueType.getTypeId()public IntSet getWaiting()
ILockValue
getWaiting in interface ILockValuepublic ILockValue clone(Map<Object,Object> cloneMap)
ILockValue
clone in interface ILockValueclone in interface INonPrimitiveValueclone in interface IValuecloneMap - Original values (IValue) to their clones (
IValue) mapping. The clone map to solve
circular references in values. If this value is a key in the
map, then this method returns the value of the key in the map.
Must be non-null.
public void dispose()
Disposable
dispose in interface Disposable
public byte[][] linearize(int bitsPerNonPrimitiveValue,
ObjectIntTable nonPrimitiveValueIdMap,
int bitsPerThreadId,
IntIntTable threadOrderMap)
ILockValue
linearize in interface ILockValuebitsPerNonPrimitiveValue - The number of bits used to encode a non-primitive value.nonPrimitiveValueIdMap - A mapping of non-primitive values to their unique id. Must be
non-null.bitsPerThreadId - The number of bits used to encode a thread descriptor.threadOrderMap - A mapping of thread descriptors to their order number. Must be
non-null.
public void opLock(int threadId)
ILockValue
opLock in interface ILockValuethreadId - The thread id that wants to lock this lock value.
public void opNotify(int threadId,
int nextThreadId)
ILockValue
opNotify in interface ILockValuethreadId - The thread id that wants to notify this lock value. This
thread id must be contained in this lock value's wait set.nextThreadId - If not EPSILON, then this thread id is
notified (put to this lock value's notification set).public void opNotifyAll(int threadId)
ILockValue
opNotifyAll in interface ILockValuethreadId - The thread id that wants to notify this lock value.public void opUnlock(int threadId)
ILockValue
opUnlock in interface ILockValuethreadId - The thread id that wants to unlock this lock value.
public void opUnwait(int threadId,
int i)
ILockValuei.
The thread is then removed from the notification set.
opUnwait in interface ILockValuethreadId - The thread id that wants to unwait this lock value.i - The lock counter of this lock value for the given thread. Must
be at least one.public int opWait(int threadId)
ILockValue
opWait in interface ILockValuethreadId - The thread id that wants to wait this lock value.
public boolean testHasLock(int threadId)
ILockValue
testHasLock in interface ILockValuethreadId - The thread id that wants to test whether it holds this lock
value.
public boolean testLockAvailable(int threadId)
ILockValue
testLockAvailable in interface ILockValuethreadId - The thread id that wants to test this lock value's
availability.
public boolean testWasNotified(int threadId)
ILockValue
testWasNotified in interface ILockValuethreadId - The thread id that wants to test whether it has been notified
in this lock value.
public String toString()
IValue
toString in interface IValuetoString in class Object
public void undoOp(LockOp lockOp,
int owner,
int lockCounter,
int[] notification,
int[] waiting,
int notifiedThreadId)
ILockValue
undoOp in interface ILockValuelockOp - The lock op. Must be a valid.owner - The owner of this lock value.lockCounter - The lock counter. Must be equal or greater than 0.notification - The notification set. Must be non-null.waiting - The waiting set. Must be non-null.public void validate(IBogorConfiguration bc)
IValueFreshen references to Bogor model checking components and other non-serializable objects. Generally, this can be done in a few steps:
Model checking components (IModule implementations) should be
reacquired by fetching them from the parameter,
bc:
valueFactory = bc.getValueFactory();
scheduler = bc.getSchedulingStrategist();
Any fields storing Type objects should be treated as stale, but
still uniquely identifier by their integer typeId field. This
can be used as a key to look up the correct Type instances in the
new symbol table's typeId-to-type table:
typeField = bc.getSymbolTable().getTypeIdTypeTable().get(typeField.getTypeId());
Any IValueArray objects contained can simply be "chained" by
their IValueArray.validate(IBogorConfiguration) method:
someValueArray.validate(bc);
IValue objects contained directly should not be handled
manually by this method; they will be dealt with directly when they are visited
later
validate in interface IValuebc - The Bogor configuration to validate to.public boolean equals(Object o)
IValueIValue should provide their own
equality tests.
equals in interface IValueequals in class Objectpublic int hashCode()
IValueIValue should provide their own
hashing method.
hashCode in interface IValuehashCode in class Objectpublic int compareTo(IValue o)
compareTo in interface Comparable<IValue>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||