Removing Channel(s), tryTell etc, everything compiles but all tests are semibroken

This commit is contained in:
Viktor Klang 2011-10-22 16:06:20 +02:00
parent cccf6b4ed9
commit 1b730b5c82
96 changed files with 353 additions and 742 deletions

View file

@ -83,7 +83,7 @@ public class Pi {
double result = calculatePiFor(work.getStart(), work.getNrOfElements());
// reply with the result
getChannel().tell(new Result(result));
getSender().tell(new Result(result));
} else throw new IllegalArgumentException("Unknown message [" + message + "]");
}

View file

@ -42,8 +42,7 @@ object Pi extends App {
}
def receive = {
case Work(start, nrOfElements)
channel ! Result(calculatePiFor(start, nrOfElements)) // perform the work
case Work(start, nrOfElements) sender ! Result(calculatePiFor(start, nrOfElements)) // perform the work
}
}

View file

@ -15,7 +15,6 @@ import akka.routing.LocalConnectionManager;
import scala.Option;
import akka.actor.ActorRef;
import akka.actor.Actors;
import akka.actor.Channel;
import akka.actor.UntypedActor;
import akka.actor.UntypedActorFactory;
import akka.dispatch.Future;
@ -80,7 +79,7 @@ public class Pi {
public void onReceive(Object message) {
if (message instanceof Work) {
Work work = (Work) message;
getChannel().tell(new Result(calculatePiFor(work.getArg(), work.getNrOfElements()))); // perform the work
getSender().tell(new Result(calculatePiFor(work.getArg(), work.getNrOfElements()))); // perform the work
} else throw new IllegalArgumentException("Unknown message [" + message + "]");
}
}
@ -127,11 +126,11 @@ public class Pi {
router.tell(new Work(arg, nrOfElements), getSelf());
}
// Assume the gathering behavior
become(gather(getChannel()));
become(gather(getSender()));
}
};
private Procedure<Object> gather(final Channel<Object> recipient) {
private Procedure<Object> gather(final ActorRef recipient) {
return new Procedure<Object>() {
public void apply(Object msg) {
// handle result from the worker
@ -174,7 +173,7 @@ public class Pi {
// send calculate message
long timeout = 60000;
Future<Object> replyFuture = master.ask(new Calculate(), timeout, null);
Future<Object> replyFuture = master.ask(new Calculate(), timeout);
Option<Object> result = replyFuture.await().resultOrException();
if (result.isDefined()) {
double pi = (Double) result.get();

View file

@ -8,9 +8,9 @@ import akka.actor.Actor._
import akka.event.EventHandler
import System.{ currentTimeMillis now }
import akka.routing.Routing.Broadcast
import akka.actor.{ Timeout, Channel, Actor, PoisonPill }
import akka.routing._
import akka.AkkaApplication
import akka.actor.{ ActorRef, Timeout, Actor, PoisonPill }
object Pi extends App {
@ -40,8 +40,7 @@ object Pi extends App {
}
def receive = {
case Work(arg, nrOfElements)
channel ! Result(calculatePiFor(arg, nrOfElements)) // perform the work
case Work(arg, nrOfElements) sender ! Result(calculatePiFor(arg, nrOfElements)) // perform the work
}
}
@ -67,11 +66,11 @@ object Pi extends App {
for (arg 0 until nrOfMessages) router ! Work(arg, nrOfElements)
//Assume the gathering behavior
this become gather(channel)
this become gather(sender)
}
// phase 2, aggregate the results of the Calculation
def gather(recipient: Channel[Any]): Receive = {
def gather(recipient: ActorRef): Receive = {
case Result(value)
// handle result from the worker
pi += value