Make SecretAgent final (sorry James, you knew it couldn't last forever!) and standardised doc comment.

Add `Actor.create` factory method to 2.1->2.1 migration docs
This commit is contained in:
Kevin Wright 2013-03-06 08:20:50 +00:00
parent f305ed72a8
commit df55bc44c9
2 changed files with 6 additions and 3 deletions

View file

@ -15,14 +15,15 @@ object Agent {
def apply[T](initialValue: T)(implicit context: ExecutionContext): Agent[T] = new SecretAgent(initialValue, context) def apply[T](initialValue: T)(implicit context: ExecutionContext): Agent[T] = new SecretAgent(initialValue, context)
/** /**
* Factory method for Java Iterop. * Java API
* Factory method for creating an Agent.
*/ */
def create[T](initialValue: T, context: ExecutionContext): Agent[T] = Agent(initialValue)(context) def create[T](initialValue: T, context: ExecutionContext): Agent[T] = Agent(initialValue)(context)
/** /**
* Default agent implementation. * Default agent implementation.
*/ */
private class SecretAgent[T](initialValue: T, context: ExecutionContext) extends Agent[T] { private final class SecretAgent[T](initialValue: T, context: ExecutionContext) extends Agent[T] {
private val ref = Ref(initialValue) private val ref = Ref(initialValue)
private val updater = SerializedSuspendableExecutionContext(10)(context) private val updater = SerializedSuspendableExecutionContext(10)(context)

View file

@ -64,12 +64,14 @@ Brand new Agents
================ ================
Akka's ``Agent`` has been rewritten to improve the API and to remove the need to manually ``close`` an Agent. Akka's ``Agent`` has been rewritten to improve the API and to remove the need to manually ``close`` an Agent.
It's also now an abstract class with the potential for subtyping and has a new factory method
allowing Java to correctly infer the type of the Agent.
The Java API has also been harmonized so both Java and Scala call the same methods. The Java API has also been harmonized so both Java and Scala call the same methods.
======================================================= ======================================================= ======================================================= =======================================================
Old Java API New Java API Old Java API New Java API
======================================================= ======================================================= ======================================================= =======================================================
``new Agent<type>(value, actorSystem)`` ``new Agent<type>(value, executionContext)`` ``new Agent<type>(value, actorSystem)`` ``Agent.create(value, executionContext)``
``agent.update(newValue)`` ``agent.send(newValue)`` ``agent.update(newValue)`` ``agent.send(newValue)``
``agent.future(Timeout)`` ``agent.future()`` ``agent.future(Timeout)`` ``agent.future()``
``agent.await(Timeout)`` ``Await.result(agent.future(), Timeout)`` ``agent.await(Timeout)`` ``Await.result(agent.future(), Timeout)``