use of com.arjuna.ats.txoj.Lock in project narayana by jbosstm.
the class LockList method pop.
/*
* Pop the first element off the list and return it.
*/
public final Lock pop() {
Lock current;
if (count == 0)
return null;
current = (Lock) head;
count--;
head = LockFriend.getLink(head);
LockFriend.setLink(current, null);
return current;
}
use of com.arjuna.ats.txoj.Lock in project narayana by jbosstm.
the class LockList method forgetNext.
/*
* Discard the element following the one pointed at. If it is the first
* element (current = 0) then simply change the head pointer. Beware if
* current points at the last element or the list is empty! This probably
* indicates a bug in the caller.
*/
public final void forgetNext(Lock current) {
if (count > 0) /* something there to forget */
{
if (current == null)
head = LockFriend.getLink(head);
else {
Lock nextOne = LockFriend.getLink(current);
if (nextOne != null)
LockFriend.setLink(current, LockFriend.getLink(nextOne));
else {
/*
* Probably an error - being asked to forget element after
* end of list
*/
count++;
LockFriend.setLink(current, null);
/* force end of list */
}
}
count--;
}
}
use of com.arjuna.ats.txoj.Lock in project narayana by jbosstm.
the class AtomicObject method incr.
public void incr(int value) throws TestException {
AtomicAction A = new AtomicAction();
A.begin();
if (setlock(new Lock(LockMode.WRITE), retry) == LockResult.GRANTED) {
state += value;
if (A.commit() != ActionStatus.COMMITTED)
throw new TestException("Action commit error.");
else
return;
} else {
if (printDebug)
System.out.println("Error - could not set write lock.");
}
A.abort();
throw new TestException("Write lock error.");
}
use of com.arjuna.ats.txoj.Lock in project narayana by jbosstm.
the class AtomicObjectLog method set.
public void set(int value) throws TestException {
AtomicAction A = new AtomicAction();
A.begin();
if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED) {
state = value;
if (A.commit() != ActionStatus.COMMITTED)
throw new TestException("Action commit error.");
else
return;
} else {
if (printDebug)
System.out.println("Error - could not set write lock.");
}
A.abort();
throw new TestException("Write lock error.");
}
use of com.arjuna.ats.txoj.Lock in project narayana by jbosstm.
the class RecoverableObject method get.
public int get() {
AtomicAction A = new AtomicAction();
int value = -1;
A.begin();
if (setlock(new Lock(LockMode.READ)) == LockResult.GRANTED) {
value = state;
if (A.commit() == ActionStatus.COMMITTED)
return value;
else
return -1;
}
A.abort();
return -1;
}
Aggregations