diff --git a/akka-core/src/main/scala/stm/Transaction.scala b/akka-core/src/main/scala/stm/Transaction.scala index 221ab86bd6..9581d46546 100644 --- a/akka-core/src/main/scala/stm/Transaction.scala +++ b/akka-core/src/main/scala/stm/Transaction.scala @@ -22,81 +22,6 @@ import org.multiverse.stms.alpha.AlphaStm class NoTransactionInScopeException extends RuntimeException class TransactionRetryException(message: String) extends RuntimeException(message) -/** - * Example of atomic transaction management using the atomic block. - * These blocks takes an implicit argument String defining the transaction family name. - * If these blocks are used from within an Actor then the name is automatically resolved, if not either: - * 1. define an implicit String with the name in the same scope - * 2. pass in the name explicitly - * - * Here are some examples (assuming implicit transaction family name in scope): - *
- * import se.scalablesolutions.akka.stm.Transaction._
- *
- * atomic {
- * .. // do something within a transaction
- * }
- *
- *
- * Example of atomic transaction management using atomic block with retry count:
- *
- * import se.scalablesolutions.akka.stm.Transaction._
- *
- * atomic(maxNrOfRetries) {
- * .. // do something within a transaction
- * }
- *
- *
- * Example of atomically-orElse transaction management.
- * Which is a good way to reduce contention and transaction collisions.
- *
- * import se.scalablesolutions.akka.stm.Transaction._
- *
- * atomically {
- * .. // try to do something
- * } orElse {
- * .. // if transaction clashes try do do something else to minimize contention
- * }
- *
- *
- * Example of atomic transaction management using for comprehensions (monadic):
- *
- *
- * import se.scalablesolutions.akka.stm.Transaction._
- * for (tx <- Transaction) {
- * ... // do transactional stuff
- * }
- *
- * val result = for (tx <- Transaction) yield {
- * ... // do transactional stuff yielding a result
- * }
- *
- *
- * Example of using Transaction and TransactionalRef in for comprehensions (monadic):
- *
- *
- * // For example, if you have a List with TransactionalRef
- * val refs: List[TransactionalRef] = ...
- *
- * // You can use them together with Transaction in a for comprehension since
- * // TransactionalRef is also monadic
- * for {
- * tx <- Transaction
- * ref <- refs
- * } {
- * ... // use the ref inside a transaction
- * }
- *
- * val result = for {
- * tx <- Transaction
- * ref <- refs
- * } yield {
- * ... // use the ref inside a transaction, yield a result
- * }
- *
- *
- * @author Jonas Bonér
- */
object Transaction {
val idFactory = new AtomicLong(-1L)
@@ -110,6 +35,71 @@ object Transaction {
def execute(mtx: MultiverseTransaction): T = body
}.execute()
+ /**
+ * Module for "local" transaction management, local in the context of threads.
+ * You should only use these if you do not need to have one transaction span
+ * multiple threads (or Actors).
+ *
+ * Example of atomic transaction management using the atomic block.
+ *
+ *
+ * import se.scalablesolutions.akka.stm.Transaction.Local._
+ *
+ * atomic {
+ * .. // do something within a transaction
+ * }
+ *
+ *
+ * Example of atomically-orElse transaction management.
+ * Which is a good way to reduce contention and transaction collisions.
+ *
+ * import se.scalablesolutions.akka.stm.Transaction.Local._
+ *
+ * atomically {
+ * .. // try to do something
+ * } orElse {
+ * .. // if transaction clashes try do do something else to minimize contention
+ * }
+ *
+ *
+ * Example of atomic transaction management using for comprehensions (monadic):
+ *
+ *
+ * import se.scalablesolutions.akka.stm.Transaction.Local._
+ * for (tx <- Transaction) {
+ * ... // do transactional stuff
+ * }
+ *
+ * val result = for (tx <- Transaction) yield {
+ * ... // do transactional stuff yielding a result
+ * }
+ *
+ *
+ * Example of using Transaction and TransactionalRef in for comprehensions (monadic):
+ *
+ *
+ * // For example, if you have a List with TransactionalRef
+ * val refs: List[TransactionalRef] = ...
+ *
+ * // You can use them together with Transaction in a for comprehension since
+ * // TransactionalRef is also monadic
+ * for {
+ * tx <- Transaction
+ * ref <- refs
+ * } {
+ * ... // use the ref inside a transaction
+ * }
+ *
+ * val result = for {
+ * tx <- Transaction
+ * ref <- refs
+ * } yield {
+ * ... // use the ref inside a transaction, yield a result
+ * }
+ *
+ *
+ * @author Jonas Bonér
+ */
object Local extends TransactionManagement with Logging {
/**
@@ -166,6 +156,59 @@ object Transaction {
}
}
+ /**
+ * Module for "global" transaction management, global in the context of multiple threads.
+ * You have to use these if you do need to have one transaction span multiple threads (or Actors).
+ *
+ * Example of atomic transaction management using the atomic block.
+ *
+ * Here are some examples (assuming implicit transaction family name in scope):
+ *
+ * import se.scalablesolutions.akka.stm.Transaction.Global._
+ *
+ * atomic {
+ * .. // do something within a transaction
+ * }
+ *
+ *
+ * Example of atomic transaction management using for comprehensions (monadic):
+ *
+ *
+ * import se.scalablesolutions.akka.stm.Transaction.Global_
+ * for (tx <- Transaction) {
+ * ... // do transactional stuff
+ * }
+ *
+ * val result = for (tx <- Transaction) yield {
+ * ... // do transactional stuff yielding a result
+ * }
+ *
+ *
+ * Example of using Transaction and TransactionalRef in for comprehensions (monadic):
+ *
+ *
+ * // For example, if you have a List with TransactionalRef
+ * val refs: List[TransactionalRef] = ...
+ *
+ * // You can use them together with Transaction in a for comprehension since
+ * // TransactionalRef is also monadic
+ * for {
+ * tx <- Transaction
+ * ref <- refs
+ * } {
+ * ... // use the ref inside a transaction
+ * }
+ *
+ * val result = for {
+ * tx <- Transaction
+ * ref <- refs
+ * } yield {
+ * ... // use the ref inside a transaction, yield a result
+ * }
+ *
+ *
+ * @author Jonas Bonér
+ */
object Global extends TransactionManagement with Logging {
/**
* See ScalaDoc on Transaction class.
diff --git a/akka-kernel/src/main/scala/Kernel.scala b/akka-kernel/src/main/scala/Kernel.scala
index 6c0cd87058..6154e26ab2 100644
--- a/akka-kernel/src/main/scala/Kernel.scala
+++ b/akka-kernel/src/main/scala/Kernel.scala
@@ -79,14 +79,14 @@ object Kernel extends Logging {
log.info(
"""
==============================
- __ __
+ __ __
_____ | | _| | _______
\__ \ | |/ / |/ /\__ \
/ __ \| <| < / __ \_
(____ /__|_ \__|_ \(____ /
\/ \/ \/ \/
""")
- log.info(" Running version %s", Config.VERSION)
+ log.info(" Running version %s", Config.VERSION)
log.info("==============================")
}
}
diff --git a/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala b/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala
index 6f1d93feb6..6d4bf9679e 100644
--- a/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala
+++ b/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala
@@ -2,7 +2,7 @@
* Copyright (C) 2009-2010 Scalable Solutions AB