use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class ExtendedLinkedListUnitTest method testLinkedList.
public void testLinkedList() throws Exception {
NodeImple ni1 = new NodeImple("one");
NodeImple ni2 = new NodeImple("two");
NodeImple ni3 = new NodeImple("three");
AtomicAction A = new AtomicAction();
Node h1 = theContainer.enlist(ni1);
Node h2 = theContainer.enlist(ni2);
Node h3 = theContainer.enlist(ni3);
h1.setNext(h2);
h2.setPrev(h1);
assertEquals(h1.getPrev(), null);
assertEquals(h2.getPrev().nodeName(), h1.nodeName());
A.begin();
h1.setNext(h3);
h2.setPrev(null);
h3.setPrev(h1);
A.abort();
assertEquals(h1.getNext().nodeName(), h2.nodeName());
assertEquals(h1.getPrev(), null);
assertEquals(h2.getPrev().nodeName(), h1.nodeName());
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class LockFreeUnitTest method test.
public void test() {
Container<Sample> theContainer = new Container<Sample>();
Sample obj = theContainer.create(new SampleLockable(10));
assertTrue(obj != null);
AtomicAction act = new AtomicAction();
System.err.println("Started transaction: " + act);
act.begin();
boolean result = obj.increment();
assertTrue(result);
result = obj.decrement();
assertTrue(result);
act.commit();
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class AtomicLinkedListUnitTest method testLinkedList.
public void testLinkedList() throws Exception {
ExtendedAtomicLinkedList ni1 = new LinkedListEntry("one");
ExtendedAtomicLinkedList ni2 = new LinkedListEntry("two");
ExtendedAtomicLinkedList ni3 = new LinkedListEntry("three");
AtomicAction A = new AtomicAction();
ExtendedAtomicLinkedList h1 = theContainer.enlist(ni1);
ExtendedAtomicLinkedList h2 = theContainer.enlist(ni2);
ExtendedAtomicLinkedList h3 = theContainer.enlist(ni3);
h1.setNext(h2);
h2.setPrev(h1);
assertEquals(h1.getPrev(), null);
assertEquals(((ExtendedAtomicLinkedList) h2.getPrev()).nodeName(), h1.nodeName());
A.begin();
h1.setNext(h3);
h2.setPrev(null);
h3.setPrev(h1);
A.abort();
assertEquals(((ExtendedAtomicLinkedList) h1.getNext()).nodeName(), h2.nodeName());
assertEquals(h1.getPrev(), null);
assertEquals(((ExtendedAtomicLinkedList) h2.getPrev()).nodeName(), h1.nodeName());
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class Service01 method setupOper.
/**
* passing in true to this operation will force the records to be enlisted into a new transaction
* nesting the new transaction within any other running transaction.
*/
public void setupOper(boolean nest) {
// create abstract records
mTransaction = (AtomicAction) AtomicAction.Current();
if (nest || mTransaction == null) {
mTransaction = new AtomicAction();
mTransaction.begin();
}
qautil.qadebug("createing abstract records and enlisting them");
mAbstractRecordList = new BasicAbstractRecord[mNumberOfResources];
// set up abstract records
for (int i = 0; i < mNumberOfResources; i++) {
mAbstractRecordList[i] = new BasicAbstractRecord();
if (mTransaction.add(mAbstractRecordList[i]) != AddOutcome.AR_ADDED) {
qautil.debug("Error when adding: " + i + " to atomic action");
mCorrect = false;
}
}
mNest = nest;
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class ThreadActionTest method testOthers.
@Test
public void testOthers() {
DummySetup ds = new DummySetup();
ThreadActionData.addSetup(ds);
AtomicAction A = new AtomicAction();
AtomicAction B = new AtomicAction();
A.begin();
B.begin();
assertTrue(ThreadActionData.currentAction() != null);
ThreadActionData.restoreActions(B);
assertEquals(ThreadActionData.popAction(), B);
ThreadActionData.purgeActions(Thread.currentThread());
assertTrue(ds.called());
ThreadActionData.removeSetup(ds);
ThreadActionData.popAction(Thread.currentThread().getName());
}
Aggregations