예제 #1
0
 @Test
 public void libTxn_6() {
   long x =
       Txn.executeWriteReturn(
           unit,
           () -> {
             counter2.inc();
             assertEquals("In W, value()", 0, counter2.value());
             assertEquals("In W, get()", 1, counter2.get());
             return counter2.get();
           });
   assertEquals("Outside W", 1, x);
 }
예제 #2
0
 @Test
 public void libTxn_7() {
   long x1 =
       Txn.executeWriteReturn(
           unit,
           () -> {
             counter2.inc();
             counter2.inc();
             return counter2.get();
           });
   long x2 =
       Txn.executeReadReturn(
           unit,
           () -> {
             return counter2.get();
           });
   assertEquals("After W and R", x1, x2);
 }