use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class AtomicObjectTest1 method incr21.
private static void incr21(char thr, int level) {
boolean res = true;
boolean res1 = true;
boolean res2 = true;
int ran;
AtomicAction a = new AtomicAction();
a.begin();
indent(thr, level);
System.out.println("begin incr21");
ran = Math.abs(rand.nextInt()) % 16;
try {
atomicObject2.incr(ran);
} catch (TestException e) {
res = res1 = false;
}
indent(thr, level);
System.out.println("part1 incr21 : " + res1);
if (res) {
try {
atomicObject1.incr(-ran);
} catch (TestException e) {
res = res2 = false;
}
indent(thr, level);
System.out.println("part2 incr21 : " + res2);
} else
res2 = false;
indent(thr, level);
if (res) {
System.out.print("commit ");
res = (boolean) (a.commit() == ActionStatus.COMMITTED);
} else {
System.out.print("abort ");
a.abort();
}
System.out.println(" incr21 : " + res1 + " : " + res2 + " : " + res + " : " + ran);
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class AtomicObjectTest3 method get12.
private static void get12(int thr, int level) {
boolean res = true;
boolean res1 = true;
boolean res2 = true;
int value1 = 0;
int value2 = 0;
AtomicAction a = new AtomicAction();
a.begin();
indent(thr, level);
System.out.println("begin get12");
try {
value1 = atomicObject1.get();
} catch (TestException e) {
res = res1 = false;
}
indent(thr, level);
System.out.println("part1 get12 : " + res1);
lowProbYield();
if (res) {
try {
value2 = atomicObject2.get();
} catch (TestException e) {
res = res2 = false;
}
indent(thr, level);
System.out.println("part2 get12 : " + res2);
} else
res2 = false;
lowProbYield();
indent(thr, level);
if (res) {
System.out.print("commit ");
res = (boolean) (a.commit() == ActionStatus.COMMITTED);
} else {
System.out.print("abort ");
a.abort();
}
System.out.println(" get12 : " + res1 + " : " + res2 + " : " + res + " : " + value1 + " : " + value2);
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class AtomicObjectTest3 method incr12.
private static void incr12(int thr, int level) {
boolean res = true;
boolean res1 = true;
boolean res2 = true;
int ran;
AtomicAction a = new AtomicAction();
a.begin();
indent(thr, level);
System.out.println("begin incr12");
ran = Math.abs(rand.nextInt()) % 16;
try {
atomicObject1.incr(ran);
} catch (TestException e) {
res = res1 = false;
}
indent(thr, level);
System.out.println("part1 incr12 : " + res1 + " " + res);
lowProbYield();
if (res) {
try {
atomicObject2.incr(-ran);
} catch (TestException e) {
res = res2 = false;
}
indent(thr, level);
System.out.println("part2 incr12 : " + res2);
} else
res2 = false;
lowProbYield();
indent(thr, level);
if (res) {
System.out.flush();
System.out.print("commit ");
System.out.flush();
res = (boolean) (a.commit() == ActionStatus.COMMITTED);
} else {
System.out.flush();
System.out.print("abort ");
System.out.flush();
a.abort();
}
System.out.println(" incr12 : " + res1 + " : " + res2 + " : " + res + " : " + ran);
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class AtomicObjectTest3 method get21.
private static void get21(int thr, int level) {
boolean res = true;
boolean res1 = true;
boolean res2 = true;
int value1 = 0;
int value2 = 0;
AtomicAction a = new AtomicAction();
a.begin();
indent(thr, level);
System.out.println("begin get21");
try {
value1 = atomicObject2.get();
} catch (TestException e) {
res = res1 = false;
}
indent(thr, level);
System.out.println("part1 get21 : " + res1);
lowProbYield();
if (res) {
try {
value2 = atomicObject1.get();
} catch (TestException e) {
res = res2 = false;
}
indent(thr, level);
System.out.println("part2 get21 : " + res2);
} else
res2 = false;
lowProbYield();
indent(thr, level);
if (res) {
System.out.print("commit ");
res = (boolean) (a.commit() == ActionStatus.COMMITTED);
} else {
System.out.print("abort ");
a.abort();
}
System.out.println(" get21 : " + res1 + " : " + res2 + " : " + res + " : " + value1 + " : " + value2);
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class CommitObject method run.
public void run() {
int thr = nextThreadId;
nextThreadId++;
AtomicAction a = new AtomicAction();
a.begin();
AtomicObjectTest3.indent(thr, 0);
System.out.println("begin");
AtomicObjectTest3.randomOperation(thr, 0);
AtomicObjectTest3.randomOperation(thr, 0);
a.commit();
AtomicObjectTest3.indent(thr, 0);
System.out.println("commit");
}
Aggregations