use of org.apache.jena.sparql.core.Transactional in project jena by apache.
the class TestTxn method txn_threaded_02.
// // This would lock up.
// public void txn_threaded_Not_A_Test() {
// Txn.exec(counter, TxnType.READ_PROMOTE, ()->{
// ThreadAction a = ThreadTxn.threadTxnWrite(counter, ()->{});
// // a is in a W transaction but has not committed or aborted - it's paused.
// boolean b = counter.promote();
// // Never reach here.
// a.run();
// });
// }
@Test
public void txn_threaded_02() {
// Transactional tx = DatasetGraphFactory.createTxnMem();
Transactional tx = counter;
// Start and enter the W transaction.
ThreadAction a = ThreadTxn.threadTxnWrite(tx, () -> {
});
// ThreadAction started ... in W transaction.
Txn.exec(tx, TxnType.READ_PROMOTE, () -> {
// ... have the thread action complete.
a.run();
// Blocks promotion.
boolean b = tx.promote();
assertFalse(b);
assertEquals(ReadWrite.READ, tx.transactionMode());
});
}
Aggregations