Renaming sendOneWay to tell, closing ticket #1072
This commit is contained in:
parent
29ca6a867b
commit
04729bcbc3
32 changed files with 94 additions and 94 deletions
|
|
@ -81,7 +81,7 @@ You can also set the thread to a reference to be able to control its life-cycle:
|
|||
|
||||
... // time passes
|
||||
|
||||
t.sendOneWay(new Exit()); // shut down the thread
|
||||
t.tell(new Exit()); // shut down the thread
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
|
@ -190,6 +190,6 @@ Example in Akka:
|
|||
});
|
||||
|
||||
// shut down the threads
|
||||
main.sendOneWay(new Exit());
|
||||
setY.sendOneWay(new Exit());
|
||||
setV.sendOneWay(new Exit());
|
||||
main.tell(new Exit());
|
||||
setY.tell(new Exit());
|
||||
setV.tell(new Exit());
|
||||
|
|
|
|||
|
|
@ -176,13 +176,13 @@ Creating a PriorityDispatcher using PriorityGenerator:
|
|||
|
||||
ref.start(); // Start the actor
|
||||
ref.getDispatcher().suspend(ref); // Suspending the actor so it doesn't start to treat the messages before we have enqueued all of them :-)
|
||||
ref.sendOneWay("lowpriority");
|
||||
ref.sendOneWay("lowpriority");
|
||||
ref.sendOneWay("highpriority");
|
||||
ref.sendOneWay("pigdog");
|
||||
ref.sendOneWay("pigdog2");
|
||||
ref.sendOneWay("pigdog3");
|
||||
ref.sendOneWay("highpriority");
|
||||
ref.tell("lowpriority");
|
||||
ref.tell("lowpriority");
|
||||
ref.tell("highpriority");
|
||||
ref.tell("pigdog");
|
||||
ref.tell("pigdog2");
|
||||
ref.tell("pigdog3");
|
||||
ref.tell("highpriority");
|
||||
ref.getDispatcher().resume(ref); // Resuming the actor so it will start treating its messages
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ A child actor can tell the supervising actor to unlink him by sending him the 'U
|
|||
.. code-block:: java
|
||||
|
||||
ActorRef supervisor = getContext().getSupervisor();
|
||||
if (supervisor != null) supervisor.sendOneWay(new Unlink(getContext()))
|
||||
if (supervisor != null) supervisor.tell(new Unlink(getContext()))
|
||||
|
||||
The supervising actor's side of things
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ In Akka, a `Future <http://en.wikipedia.org/wiki/Futures_and_promises>`_ is a da
|
|||
Use with Actors
|
||||
---------------
|
||||
|
||||
There are generally two ways of getting a reply from an ``UntypedActor``: the first is by a sent message (``actorRef.sendOneWay(msg);``), which only works if the original sender was an ``UntypedActor``) and the second is through a ``Future``.
|
||||
There are generally two ways of getting a reply from an ``UntypedActor``: the first is by a sent message (``actorRef.tell(msg);``), which only works if the original sender was an ``UntypedActor``) and the second is through a ``Future``.
|
||||
|
||||
Using the ``ActorRef``\'s ``ask`` method to send a message will return a Future. To wait for and retrieve the actual result the simplest method is:
|
||||
|
||||
|
|
|
|||
|
|
@ -625,7 +625,7 @@ Using the generated message builder to send the message to a remote actor:
|
|||
|
||||
.. code-block:: java
|
||||
|
||||
actor.sendOneWay(ProtobufPOJO.newBuilder()
|
||||
actor.tell(ProtobufPOJO.newBuilder()
|
||||
.setId(11)
|
||||
.setStatus(true)
|
||||
.setName("Coltrane")
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ An UntypedDispatcher is an actor that routes incoming messages to outbound actor
|
|||
}
|
||||
|
||||
ActorRef router = actorOf(MyRouter.class).start();
|
||||
router.sendOneWay("Ping"); //Prints "Pinger: Ping"
|
||||
router.sendOneWay("Pong"); //Prints "Ponger: Pong"
|
||||
router.tell("Ping"); //Prints "Pinger: Ping"
|
||||
router.tell("Pong"); //Prints "Ponger: Pong"
|
||||
|
||||
UntypedLoadBalancer
|
||||
-------------------
|
||||
|
|
@ -81,14 +81,14 @@ An UntypedLoadBalancer is an actor that forwards messages it receives to a bound
|
|||
}
|
||||
|
||||
ActorRef balancer = actorOf(MyLoadBalancer.class).start();
|
||||
balancer.sendOneWay("Pong"); //Prints "Pinger: Pong"
|
||||
balancer.sendOneWay("Ping"); //Prints "Ponger: Ping"
|
||||
balancer.sendOneWay("Ping"); //Prints "Pinger: Ping"
|
||||
balancer.sendOneWay("Pong"); //Prints "Ponger: Pong
|
||||
balancer.tell("Pong"); //Prints "Pinger: Pong"
|
||||
balancer.tell("Ping"); //Prints "Ponger: Ping"
|
||||
balancer.tell("Ping"); //Prints "Pinger: Ping"
|
||||
balancer.tell("Pong"); //Prints "Ponger: Pong
|
||||
|
||||
You can also send a 'new Routing.Broadcast(msg)' message to the router to have it be broadcasted out to all the actors it represents.
|
||||
|
||||
.. code-block:: java
|
||||
|
||||
balancer.sendOneWay(new Routing.Broadcast(new PoisonPill()));
|
||||
balancer.tell(new Routing.Broadcast(new PoisonPill()));
|
||||
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ Here is an example of using ``retry`` to block until an account has enough money
|
|||
|
||||
ActorRef transferer = Actors.actorOf(Transferer.class).start();
|
||||
|
||||
transferer.sendOneWay(new Transfer(account1, account2, 500.0));
|
||||
transferer.tell(new Transfer(account1, account2, 500.0));
|
||||
// Transferer: not enough money - retrying
|
||||
|
||||
new Atomic() {
|
||||
|
|
@ -428,7 +428,7 @@ You can also have two alternative blocking transactions, one of which can succee
|
|||
|
||||
ActorRef brancher = Actors.actorOf(Brancher.class).start();
|
||||
|
||||
brancher.sendOneWay(new Branch(left, right, 500));
|
||||
brancher.tell(new Branch(left, right, 500));
|
||||
// not enough on left - retrying
|
||||
// not enough on right - retrying
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ Here is an example of coordinating two simple counter UntypedActors so that they
|
|||
if (message instanceof Increment) {
|
||||
Increment increment = (Increment) message;
|
||||
if (increment.hasFriend()) {
|
||||
increment.getFriend().sendOneWay(coordinated.coordinate(new Increment()));
|
||||
increment.getFriend().tell(coordinated.coordinate(new Increment()));
|
||||
}
|
||||
coordinated.atomic(new Atomically() {
|
||||
public void atomically() {
|
||||
|
|
@ -105,7 +105,7 @@ Here is an example of coordinating two simple counter UntypedActors so that they
|
|||
ActorRef counter1 = actorOf(Counter.class).start();
|
||||
ActorRef counter2 = actorOf(Counter.class).start();
|
||||
|
||||
counter1.sendOneWay(new Coordinated(new Increment(counter2)));
|
||||
counter1.tell(new Coordinated(new Increment(counter2)));
|
||||
|
||||
To start a new coordinated transaction that you will also participate in, just create a ``Coordinated`` object:
|
||||
|
||||
|
|
@ -117,13 +117,13 @@ To start a coordinated transaction that you won't participate in yourself you ca
|
|||
|
||||
.. code-block:: java
|
||||
|
||||
actor.sendOneWay(new Coordinated(new Message()));
|
||||
actor.tell(new Coordinated(new Message()));
|
||||
|
||||
To include another actor in the same coordinated transaction that you've created or received, use the ``coordinate`` method on that object. This will increment the number of parties involved by one and create a new ``Coordinated`` object to be sent.
|
||||
|
||||
.. code-block:: java
|
||||
|
||||
actor.sendOneWay(coordinated.coordinate(new Message()));
|
||||
actor.tell(coordinated.coordinate(new Message()));
|
||||
|
||||
To enter the coordinated transaction use the atomic method of the coordinated object. This accepts either an ``akka.transactor.Atomically`` object, or an ``Atomic`` object the same as used normally in the STM (just don't execute it - the coordination will do that).
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ Send messages
|
|||
-------------
|
||||
|
||||
Messages are sent to an Actor through one of the 'send' methods.
|
||||
* 'sendOneWay' means “fire-and-forget”, e.g. send a message asynchronously and return immediately.
|
||||
* 'tell' means “fire-and-forget”, e.g. send a message asynchronously and return immediately.
|
||||
* 'sendRequestReply' means “send-and-reply-eventually”, e.g. send a message asynchronously and wait for a reply through a Future. Here you can specify a timeout. Using timeouts is very important. If no timeout is specified then the actor’s default timeout (set by the 'getContext().setTimeout(..)' method in the 'ActorRef') is used. This method throws an 'ActorTimeoutException' if the call timed out.
|
||||
* 'ask' sends a message asynchronously and returns a 'Future'.
|
||||
|
||||
|
|
@ -120,13 +120,13 @@ This is the preferred way of sending messages. No blocking waiting for a message
|
|||
|
||||
.. code-block:: java
|
||||
|
||||
actor.sendOneWay("Hello");
|
||||
actor.tell("Hello");
|
||||
|
||||
Or with the sender reference passed along:
|
||||
|
||||
.. code-block:: java
|
||||
|
||||
actor.sendOneWay("Hello", getContext());
|
||||
actor.tell("Hello", getContext());
|
||||
|
||||
If invoked from within an Actor, then the sending actor reference will be implicitly passed along with the message and available to the receiving Actor in its 'getContext().getSender();' method. He can use this to reply to the original sender or use the 'getContext().reply(message);' method.
|
||||
|
||||
|
|
@ -231,7 +231,7 @@ Reply using the channel
|
|||
|
||||
If you want to have a handle to an object to whom you can reply to the message, you can use the Channel abstraction.
|
||||
Simply call getContext().channel() and then you can forward that to others, store it away or otherwise until you want to reply,
|
||||
which you do by Channel.sendOneWay(msg)
|
||||
which you do by Channel.tell(msg)
|
||||
|
||||
.. code-block:: java
|
||||
|
||||
|
|
@ -240,7 +240,7 @@ which you do by Channel.sendOneWay(msg)
|
|||
String msg = (String)message;
|
||||
if (msg.equals("Hello")) {
|
||||
// Reply to original sender of message using the channel
|
||||
getContext().channel().sendOneWaySafe(msg + " from " + getContext().getUuid());
|
||||
getContext().channel().tellSafe(msg + " from " + getContext().getUuid());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -373,7 +373,7 @@ Use it like this:
|
|||
|
||||
import static akka.actor.Actors.*;
|
||||
|
||||
actor.sendOneWay(poisonPill());
|
||||
actor.tell(poisonPill());
|
||||
|
||||
Killing an Actor
|
||||
----------------
|
||||
|
|
@ -387,7 +387,7 @@ Use it like this:
|
|||
import static akka.actor.Actors.*;
|
||||
|
||||
// kill the actor called 'victim'
|
||||
victim.sendOneWay(kill());
|
||||
victim.tell(kill());
|
||||
|
||||
Actor life-cycle
|
||||
----------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue