Cleanup of methods in Actor and ActorContext trait. See #1377

* Added JavaActorContext, UntypedActor.getContext
* implicit val context in Actor needs to be implicit to support forward,
it would be nice if it wasn't implicit because now I can't override context
in UntypedActor
* Removed implicit def system in Actor
* Removed implicit def defaultTimeout in Actor
* Removed receiveTimeout, children, dispatcher, become, unbecome, watch,
unwatch in Actor
* Removed corresponding as above from UntypedActor
* Removed implicit from dispatcher in ActorSystem
* Removed implicit def timeout in TypedActor
* Changed receiveTimeout to use Duration (in api)
* Changed many tests and samples to match new api
This commit is contained in:
Patrik Nordwall 2011-12-05 20:01:42 +01:00
parent 5530c4cbdb
commit 3204269f6a
56 changed files with 251 additions and 196 deletions

View file

@ -106,16 +106,16 @@ public class Pi {
this.latch = latch;
Creator<Router> routerCreator = new Creator<Router>() {
public Router create() {
return new RoundRobinRouter(dispatcher(), new akka.actor.Timeout(-1));
return new RoundRobinRouter(getContext().dispatcher(), new akka.actor.Timeout(-1));
}
};
LinkedList<ActorRef> actors = new LinkedList<ActorRef>() {
{
for (int i = 0; i < nrOfWorkers; i++) add(context().actorOf(Worker.class));
for (int i = 0; i < nrOfWorkers; i++) add(getContext().actorOf(Worker.class));
}
};
RoutedProps props = new RoutedProps(routerCreator, new LocalConnectionManager(actors), new akka.actor.Timeout(-1), true);
router = new RoutedActorRef(system(), props, getSelf(), "pi");
router = new RoutedActorRef(getContext().system(), props, getSelf(), "pi");
}
// message handler

View file

@ -52,11 +52,14 @@ object Pi extends App {
var start: Long = _
// create the workers
val workers = Vector.fill(nrOfWorkers)(system.actorOf[Worker])
val workers = Vector.fill(nrOfWorkers)(context.actorOf[Worker])
// wrap them with a load-balancing router
// FIXME routers are intended to be used like this
implicit val timout = context.system.settings.ActorTimeout
implicit val dispatcher = context.dispatcher
val props = RoutedProps(routerFactory = () new RoundRobinRouter, connectionManager = new LocalConnectionManager(workers))
val router = new RoutedActorRef(system, props, self, "pi")
val router = new RoutedActorRef(context.system, props, self, "pi")
// message handler
def receive = {