Exemple #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);
 }
Exemple #2
0
 @Test
 public void libTxnThread_10() {
   long x1 = counter1.get();
   ThreadTxn t =
       Txn.threadTxnWrite(
           unit,
           () -> {
             counter1.inc();
           });
   long x2 = counter1.get();
   assertEquals("x2", x1, x2);
   t.run();
   long x3 = counter1.get();
   assertEquals("x3", x1 + 1, x3);
 }
Exemple #3
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);
 }
Exemple #4
0
 @Test(expected = AssertionError.class)
 public void libTxnThread_3() {
   ThreadTxn t = Txn.threadTxnWrite(unit, () -> fail(""));
   t.run();
 }
Exemple #5
0
 @Test
 public void libTxnThread_1() {
   ThreadTxn t = Txn.threadTxnRead(unit, () -> {});
   t.run();
 }