public void doRun() { GammaTxnLong ref = new GammaTxnLong(stm); // FatArrayTreeGammaTxn tx = new FatArrayTreeGammaTxn(stm); // FatArrayGammaTxn tx = new FatArrayGammaTxn(stm,1); FatMonoGammaTxn tx = new FatMonoGammaTxn( new GammaTxnConfig(stm) .setReadLockMode(LockMode.Exclusive) .setDirtyCheckEnabled(false)); long startMs = System.currentTimeMillis(); for (long k = 0; k < transactionCount; k++) { ref.openForWrite(tx, LOCKMODE_EXCLUSIVE).long_value++; tx.commit(); tx.hardReset(); // if (k % 100000000 == 0 && k > 0) { // System.out.printf("%s is at %s\n", getName(), k); // } } assertEquals(transactionCount, ref.atomicGet()); durationMs = System.currentTimeMillis() - startMs; System.out.printf("Multiverse> %s is finished in %s ms\n", getName(), durationMs); }
@Test public void test() { final GammaTxnLong ref = new GammaTxnLong(stm); WaitThread t = new WaitThread(ref); t.start(); sleepMs(1000); assertAlive(t); stm.getDefaultTxnExecutor() .execute( new TxnVoidCallable() { @Override public void call(Txn tx) throws Exception { GammaTxn btx = (GammaTxn) tx; Tranlocal write = ref.openForWrite(btx, LOCKMODE_NONE); write.long_value = 1; } }); joinAll(t); assertEquals(2, ref.atomicGet()); }