Example #1
0
 @Test
 public void libTxnThread_12() {
   long x1 = counter1.get();
   ThreadTxn t =
       Txn.threadTxnRead(
           unit,
           () -> {
             long z1 = counter1.get();
             assertEquals("Thread", x1, z1);
           });
   Txn.executeWrite(unit, () -> counter1.inc());
   t.run();
   long x2 = counter1.get();
   assertEquals("after", x1 + 1, x2);
 }
Example #2
0
 @Test
 public void libTxnThread_11() {
   long x1 = counter1.get();
   Txn.executeWrite(
       unit,
       () -> {
         counter1.inc();
         // Read the "before" state
         ThreadTxn t =
             Txn.threadTxnRead(
                 unit,
                 () -> {
                   long z1 = counter1.get();
                   assertEquals("Thread read", x1, z1);
                 });
         counter1.inc();
         t.run();
       });
   long x2 = counter1.get();
   assertEquals("after", x1 + 2, x2);
 }
Example #3
0
 @Test
 public void libTxnThread_1() {
   ThreadTxn t = Txn.threadTxnRead(unit, () -> {});
   t.run();
 }