Agent is now monadic, added more tests to AgentTest
This commit is contained in:
parent
7d465f6d4f
commit
089cf01b40
4 changed files with 154 additions and 78 deletions
|
|
@ -103,33 +103,29 @@ object Transaction extends TransactionManagement with Logging {
|
|||
/**
|
||||
* See ScalaDoc on Transaction class.
|
||||
*/
|
||||
def map[T](f: => T)(implicit transactionFamilyName: String): T =
|
||||
atomic {f}
|
||||
def map[T](f: => T): T = atomic {f}
|
||||
|
||||
/**
|
||||
* See ScalaDoc on Transaction class.
|
||||
*/
|
||||
def flatMap[T](f: => T)(implicit transactionFamilyName: String): T =
|
||||
atomic {f}
|
||||
def flatMap[T](f: => T): T = atomic {f}
|
||||
|
||||
/**
|
||||
* See ScalaDoc on Transaction class.
|
||||
*/
|
||||
def foreach(f: => Unit)(implicit transactionFamilyName: String): Unit =
|
||||
atomic {f}
|
||||
def foreach(f: => Unit): Unit = atomic {f}
|
||||
|
||||
/**
|
||||
* See ScalaDoc on Transaction class.
|
||||
*/
|
||||
def atomic[T](body: => T)(implicit transactionFamilyName: String): T = {
|
||||
def atomic[T](body: => T): T = {
|
||||
var isTopLevelTransaction = true
|
||||
new TransactionTemplate[T]() {
|
||||
def execute(mtx: MultiverseTransaction): T = {
|
||||
val result = body
|
||||
|
||||
val txSet = getTransactionSetInScope
|
||||
log.trace("Committing transaction [%s]\n\twith family name [%s]\n\tby joining transaction set [%s]",
|
||||
mtx, transactionFamilyName, txSet)
|
||||
log.trace("Committing transaction [%s]\n\tby joining transaction set [%s]", mtx, txSet)
|
||||
txSet.joinCommit(mtx)
|
||||
|
||||
// FIXME tryJoinCommit(mtx, TransactionManagement.TRANSACTION_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue