#2934 - explaining send a bit better in the docs

This commit is contained in:
Viktor Klang 2013-01-27 21:47:05 +01:00
parent 68f3dd549d
commit 791bbd1565
3 changed files with 10 additions and 11 deletions

View file

@ -4,14 +4,9 @@
package akka.agent package akka.agent
import akka.actor._
import akka.japi.{ Function JFunc, Procedure JProc }
import akka.pattern.ask
import scala.concurrent.stm._ import scala.concurrent.stm._
import scala.concurrent.{ ExecutionContext, Future, Promise, Await } import scala.concurrent.{ ExecutionContext, Future, Promise }
import scala.concurrent.duration.{ FiniteDuration, Duration } import akka.util.{ SerializedSuspendableExecutionContext }
import akka.util.{ SerializedSuspendableExecutionContext, Timeout }
import util.Try
/** /**
* Factory method for creating an Agent. * Factory method for creating an Agent.

View file

@ -55,10 +55,12 @@ public class AgentDocTest {
Agent<Integer> agent = new Agent<Integer>(5, ec); Agent<Integer> agent = new Agent<Integer>(5, ec);
//#send //#send
// send a value // send a value, enqueues this change
// of the value of the Agent
agent.send(7); agent.send(7);
// send a function // send a Mapper, enqueues this change
// to the value of the Agent
agent.send(new Mapper<Integer, Integer>() { agent.send(new Mapper<Integer, Integer>() {
public Integer apply(Integer i) { public Integer apply(Integer i) {
return i * 2; return i * 2;

View file

@ -48,10 +48,12 @@ class AgentDocSpec extends AkkaSpec {
"send and sendOff" in { "send and sendOff" in {
val agent = Agent(0)(ExecutionContext.global) val agent = Agent(0)(ExecutionContext.global)
//#send //#send
// send a value // send a value, enqueues this change
// of the value of the Agent
agent send 7 agent send 7
// send a function // send a function, enqueues this change
// to the value of the Agent
agent send (_ + 1) agent send (_ + 1)
agent send (_ * 2) agent send (_ * 2)
//#send //#send