#2934 - explaining send a bit better in the docs
This commit is contained in:
parent
68f3dd549d
commit
791bbd1565
3 changed files with 10 additions and 11 deletions
|
|
@ -4,14 +4,9 @@
|
|||
|
||||
package akka.agent
|
||||
|
||||
import akka.actor._
|
||||
import akka.japi.{ Function ⇒ JFunc, Procedure ⇒ JProc }
|
||||
import akka.pattern.ask
|
||||
import scala.concurrent.stm._
|
||||
import scala.concurrent.{ ExecutionContext, Future, Promise, Await }
|
||||
import scala.concurrent.duration.{ FiniteDuration, Duration }
|
||||
import akka.util.{ SerializedSuspendableExecutionContext, Timeout }
|
||||
import util.Try
|
||||
import scala.concurrent.{ ExecutionContext, Future, Promise }
|
||||
import akka.util.{ SerializedSuspendableExecutionContext }
|
||||
|
||||
/**
|
||||
* Factory method for creating an Agent.
|
||||
|
|
|
|||
|
|
@ -55,10 +55,12 @@ public class AgentDocTest {
|
|||
Agent<Integer> agent = new Agent<Integer>(5, ec);
|
||||
|
||||
//#send
|
||||
// send a value
|
||||
// send a value, enqueues this change
|
||||
// of the value of the Agent
|
||||
agent.send(7);
|
||||
|
||||
// send a function
|
||||
// send a Mapper, enqueues this change
|
||||
// to the value of the Agent
|
||||
agent.send(new Mapper<Integer, Integer>() {
|
||||
public Integer apply(Integer i) {
|
||||
return i * 2;
|
||||
|
|
|
|||
|
|
@ -48,10 +48,12 @@ class AgentDocSpec extends AkkaSpec {
|
|||
"send and sendOff" in {
|
||||
val agent = Agent(0)(ExecutionContext.global)
|
||||
//#send
|
||||
// send a value
|
||||
// send a value, enqueues this change
|
||||
// of the value of the Agent
|
||||
agent send 7
|
||||
|
||||
// send a function
|
||||
// send a function, enqueues this change
|
||||
// to the value of the Agent
|
||||
agent send (_ + 1)
|
||||
agent send (_ * 2)
|
||||
//#send
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue