Added parens to start

This commit is contained in:
Patrik Nordwall 2011-04-12 09:55:32 +02:00
parent 97d4fc8e18
commit 087191f19f
78 changed files with 341 additions and 341 deletions

View file

@ -70,23 +70,23 @@ class ActorFireForgetRequestReplySpec extends WordSpec with MustMatchers with Be
"An Actor" must { "An Actor" must {
"reply to bang message using reply" in { "reply to bang message using reply" in {
val replyActor = actorOf[ReplyActor].start val replyActor = actorOf[ReplyActor].start()
val senderActor = actorOf(new SenderActor(replyActor)).start val senderActor = actorOf(new SenderActor(replyActor)).start()
senderActor ! "Init" senderActor ! "Init"
state.finished.await state.finished.await
state.s must be ("Reply") state.s must be ("Reply")
} }
"reply to bang message using implicit sender" in { "reply to bang message using implicit sender" in {
val replyActor = actorOf[ReplyActor].start val replyActor = actorOf[ReplyActor].start()
val senderActor = actorOf(new SenderActor(replyActor)).start val senderActor = actorOf(new SenderActor(replyActor)).start()
senderActor ! "InitImplicit" senderActor ! "InitImplicit"
state.finished.await state.finished.await
state.s must be ("ReplyImplicit") state.s must be ("ReplyImplicit")
} }
"should shutdown crashed temporary actor" in { "should shutdown crashed temporary actor" in {
val actor = actorOf[CrashingTemporaryActor].start val actor = actorOf[CrashingTemporaryActor].start()
actor.isRunning must be (true) actor.isRunning must be (true)
actor ! "Die" actor ! "Die"
state.finished.await state.finished.await

View file

@ -25,11 +25,11 @@ object ActorRefSpec {
def receive = { def receive = {
case "complexRequest" => { case "complexRequest" => {
replyTo = self.channel replyTo = self.channel
val worker = Actor.actorOf[WorkerActor].start val worker = Actor.actorOf[WorkerActor].start()
worker ! "work" worker ! "work"
} }
case "complexRequest2" => case "complexRequest2" =>
val worker = Actor.actorOf[WorkerActor].start val worker = Actor.actorOf[WorkerActor].start()
worker ! self.channel worker ! self.channel
case "workDone" => replyTo ! "complexReply" case "workDone" => replyTo ! "complexReply"
case "simpleRequest" => self.reply("simpleReply") case "simpleRequest" => self.reply("simpleReply")
@ -85,16 +85,16 @@ class ActorRefSpec extends WordSpec with MustMatchers {
val a = Actor.actorOf(new Actor { val a = Actor.actorOf(new Actor {
val nested = new Actor { def receive = { case _ => } } val nested = new Actor { def receive = { case _ => } }
def receive = { case _ => } def receive = { case _ => }
}).start }).start()
fail("shouldn't get here") fail("shouldn't get here")
} }
} }
"support nested actorOfs" in { "support nested actorOfs" in {
val a = Actor.actorOf(new Actor { val a = Actor.actorOf(new Actor {
val nested = Actor.actorOf(new Actor { def receive = { case _ => } }).start val nested = Actor.actorOf(new Actor { def receive = { case _ => } }).start()
def receive = { case _ => self reply nested } def receive = { case _ => self reply nested }
}).start }).start()
val nested = (a !! "any").get.asInstanceOf[ActorRef] val nested = (a !! "any").get.asInstanceOf[ActorRef]
a must not be null a must not be null
@ -103,8 +103,8 @@ class ActorRefSpec extends WordSpec with MustMatchers {
} }
"support reply via channel" in { "support reply via channel" in {
val serverRef = Actor.actorOf[ReplyActor].start val serverRef = Actor.actorOf[ReplyActor].start()
val clientRef = Actor.actorOf(new SenderActor(serverRef)).start val clientRef = Actor.actorOf(new SenderActor(serverRef)).start()
clientRef ! "complex" clientRef ! "complex"
clientRef ! "simple" clientRef ! "simple"
@ -134,7 +134,7 @@ class ActorRefSpec extends WordSpec with MustMatchers {
case null => self reply_? "null" case null => self reply_? "null"
} }
} }
).start ).start()
val ffive: Future[String] = ref !!! 5 val ffive: Future[String] = ref !!! 5
val fnull: Future[String] = ref !!! null val fnull: Future[String] = ref !!! null
@ -163,12 +163,12 @@ class ActorRefSpec extends WordSpec with MustMatchers {
override def preRestart(reason: Throwable) = latch.countDown override def preRestart(reason: Throwable) = latch.countDown
override def postRestart(reason: Throwable) = latch.countDown override def postRestart(reason: Throwable) = latch.countDown
} }
).start ).start()
self link ref self link ref
protected def receive = { case "sendKill" => ref ! Kill } protected def receive = { case "sendKill" => ref ! Kill }
}).start }).start()
boss ! "sendKill" boss ! "sendKill"
latch.await(5, TimeUnit.SECONDS) must be === true latch.await(5, TimeUnit.SECONDS) must be === true

View file

@ -28,7 +28,7 @@ object Chameneos {
class Chameneo(var mall: ActorRef, var colour: Colour, cid: Int) extends Actor { class Chameneo(var mall: ActorRef, var colour: Colour, cid: Int) extends Actor {
var meetings = 0 var meetings = 0
self.start self.start()
mall ! Meet(self, colour) mall ! Meet(self, colour)
def receive = { def receive = {
@ -110,7 +110,7 @@ object Chameneos {
def run { def run {
// System.setProperty("akka.config", "akka.conf") // System.setProperty("akka.config", "akka.conf")
Chameneos.start = System.currentTimeMillis Chameneos.start = System.currentTimeMillis
actorOf(new Mall(1000000, 4)).start actorOf(new Mall(1000000, 4)).start()
Thread.sleep(10000) Thread.sleep(10000)
println("Elapsed: " + (end - start)) println("Elapsed: " + (end - start))
} }

View file

@ -104,12 +104,12 @@ class FSMActorSpec extends WordSpec with MustMatchers {
"unlock the lock" in { "unlock the lock" in {
// lock that locked after being open for 1 sec // lock that locked after being open for 1 sec
val lock = Actor.actorOf(new Lock("33221", 1 second)).start val lock = Actor.actorOf(new Lock("33221", 1 second)).start()
val transitionTester = Actor.actorOf(new Actor { def receive = { val transitionTester = Actor.actorOf(new Actor { def receive = {
case Transition(_, _, _) => transitionCallBackLatch.open case Transition(_, _, _) => transitionCallBackLatch.open
case CurrentState(_, Locked) => initialStateLatch.open case CurrentState(_, Locked) => initialStateLatch.open
}}).start }}).start()
lock ! SubscribeTransitionCallBack(transitionTester) lock ! SubscribeTransitionCallBack(transitionTester)
initialStateLatch.await initialStateLatch.await
@ -137,7 +137,7 @@ class FSMActorSpec extends WordSpec with MustMatchers {
case "world" => answerLatch.open case "world" => answerLatch.open
case Bye => lock ! "bye" case Bye => lock ! "bye"
} }
}).start }).start()
tester ! Hello tester ! Hello
answerLatch.await answerLatch.await

View file

@ -11,7 +11,7 @@ class FSMTimingSpec extends WordSpec with MustMatchers with TestKit {
import FSMTimingSpec._ import FSMTimingSpec._
import FSM._ import FSM._
val fsm = Actor.actorOf(new StateMachine(testActor)).start val fsm = Actor.actorOf(new StateMachine(testActor)).start()
fsm ! SubscribeTransitionCallBack(testActor) fsm ! SubscribeTransitionCallBack(testActor)
expectMsg(200 millis, CurrentState(fsm, Initial)) expectMsg(200 millis, CurrentState(fsm, Initial))

View file

@ -32,7 +32,7 @@ object ForwardActorSpec {
class ForwardActor extends Actor { class ForwardActor extends Actor {
val receiverActor = actorOf[ReceiverActor] val receiverActor = actorOf[ReceiverActor]
receiverActor.start receiverActor.start()
def receive = { def receive = {
case "SendBang" => receiverActor.forward("SendBang") case "SendBang" => receiverActor.forward("SendBang")
case "SendBangBang" => receiverActor.forward("SendBangBang") case "SendBangBang" => receiverActor.forward("SendBangBang")
@ -41,7 +41,7 @@ object ForwardActorSpec {
class BangSenderActor extends Actor { class BangSenderActor extends Actor {
val forwardActor = actorOf[ForwardActor] val forwardActor = actorOf[ForwardActor]
forwardActor.start forwardActor.start()
forwardActor ! "SendBang" forwardActor ! "SendBang"
def receive = { def receive = {
case _ => {} case _ => {}
@ -51,7 +51,7 @@ object ForwardActorSpec {
class BangBangSenderActor extends Actor { class BangBangSenderActor extends Actor {
val latch = TestLatch() val latch = TestLatch()
val forwardActor = actorOf[ForwardActor] val forwardActor = actorOf[ForwardActor]
forwardActor.start forwardActor.start()
(forwardActor !! "SendBangBang") match { (forwardActor !! "SendBangBang") match {
case Some(_) => latch.countDown case Some(_) => latch.countDown
case None => {} case None => {}
@ -72,7 +72,7 @@ class ForwardActorSpec extends WordSpec with MustMatchers {
.forwardActor.actor.asInstanceOf[ForwardActor] .forwardActor.actor.asInstanceOf[ForwardActor]
.receiverActor.actor.asInstanceOf[ReceiverActor] .receiverActor.actor.asInstanceOf[ReceiverActor]
.latch .latch
senderActor.start senderActor.start()
latch.await latch.await
ForwardState.sender must not be (null) ForwardState.sender must not be (null)
senderActor.toString must be (ForwardState.sender.get.toString) senderActor.toString must be (ForwardState.sender.get.toString)
@ -80,7 +80,7 @@ class ForwardActorSpec extends WordSpec with MustMatchers {
"forward actor reference when invoking forward on bang bang" in { "forward actor reference when invoking forward on bang bang" in {
val senderActor = actorOf[BangBangSenderActor] val senderActor = actorOf[BangBangSenderActor]
senderActor.start senderActor.start()
val latch = senderActor.actor.asInstanceOf[BangBangSenderActor].latch val latch = senderActor.actor.asInstanceOf[BangBangSenderActor].latch
latch.await latch.await
} }

View file

@ -21,7 +21,7 @@ class HotSwapSpec extends WordSpec with MustMatchers {
@volatile var _log = "" @volatile var _log = ""
val a = actorOf( new Actor { val a = actorOf( new Actor {
def receive = { case _ => _log += "default" } def receive = { case _ => _log += "default" }
}).start }).start()
a ! HotSwap( self => { a ! HotSwap( self => {
case _ => case _ =>
_log += "swapped" _log += "swapped"
@ -46,7 +46,7 @@ class HotSwapSpec extends WordSpec with MustMatchers {
barrier.await barrier.await
}) })
} }
}).start }).start()
a ! "init" a ! "init"
barrier.await barrier.await
@ -69,7 +69,7 @@ class HotSwapSpec extends WordSpec with MustMatchers {
_log += "init" _log += "init"
barrier.await barrier.await
} }
}).start }).start()
a ! "init" a ! "init"
barrier.await barrier.await
@ -123,7 +123,7 @@ class HotSwapSpec extends WordSpec with MustMatchers {
}) })
barrier.await barrier.await
} }
}).start }).start()
a ! "init" a ! "init"
barrier.await barrier.await

View file

@ -28,7 +28,7 @@ class ReceiveTimeoutSpec extends WordSpec with MustMatchers {
protected def receive = { protected def receive = {
case ReceiveTimeout => timeoutLatch.open case ReceiveTimeout => timeoutLatch.open
} }
}).start }).start()
timeoutLatch.await timeoutLatch.await
timeoutActor.stop timeoutActor.stop
@ -43,7 +43,7 @@ class ReceiveTimeoutSpec extends WordSpec with MustMatchers {
protected def receive = { protected def receive = {
case ReceiveTimeout => timeoutLatch.open case ReceiveTimeout => timeoutLatch.open
} }
}).start }).start()
timeoutLatch.await timeoutLatch.await
@ -68,7 +68,7 @@ class ReceiveTimeoutSpec extends WordSpec with MustMatchers {
case Tick => () case Tick => ()
case ReceiveTimeout => timeoutLatch.open case ReceiveTimeout => timeoutLatch.open
} }
}).start }).start()
timeoutActor ! Tick timeoutActor ! Tick
@ -91,7 +91,7 @@ class ReceiveTimeoutSpec extends WordSpec with MustMatchers {
timeoutLatch.open timeoutLatch.open
self.receiveTimeout = None self.receiveTimeout = None
} }
}).start }).start()
timeoutActor ! Tick timeoutActor ! Tick
@ -107,7 +107,7 @@ class ReceiveTimeoutSpec extends WordSpec with MustMatchers {
protected def receive = { protected def receive = {
case ReceiveTimeout => timeoutLatch.open case ReceiveTimeout => timeoutLatch.open
} }
}).start }).start()
timeoutLatch.awaitTimeout(1 second) // timeout expected timeoutLatch.awaitTimeout(1 second) // timeout expected
timeoutActor.stop timeoutActor.stop

View file

@ -25,7 +25,7 @@ class RestartStrategySpec extends JUnitSuite {
val boss = actorOf(new Actor{ val boss = actorOf(new Actor{
self.faultHandler = OneForOneStrategy(List(classOf[Throwable]), Some(2), Some(1000)) self.faultHandler = OneForOneStrategy(List(classOf[Throwable]), Some(2), Some(1000))
protected def receive = { case _ => () } protected def receive = { case _ => () }
}).start }).start()
val restartLatch = new StandardLatch val restartLatch = new StandardLatch
val secondRestartLatch = new StandardLatch val secondRestartLatch = new StandardLatch
@ -80,7 +80,7 @@ class RestartStrategySpec extends JUnitSuite {
val boss = actorOf(new Actor{ val boss = actorOf(new Actor{
self.faultHandler = OneForOneStrategy(List(classOf[Throwable]), None, None) self.faultHandler = OneForOneStrategy(List(classOf[Throwable]), None, None)
protected def receive = { case _ => () } protected def receive = { case _ => () }
}).start }).start()
val countDownLatch = new CountDownLatch(100) val countDownLatch = new CountDownLatch(100)
@ -107,7 +107,7 @@ class RestartStrategySpec extends JUnitSuite {
val boss = actorOf(new Actor{ val boss = actorOf(new Actor{
self.faultHandler = OneForOneStrategy(List(classOf[Throwable]), Some(2), Some(500)) self.faultHandler = OneForOneStrategy(List(classOf[Throwable]), Some(2), Some(500))
protected def receive = { case _ => () } protected def receive = { case _ => () }
}).start }).start()
val restartLatch = new StandardLatch val restartLatch = new StandardLatch
val secondRestartLatch = new StandardLatch val secondRestartLatch = new StandardLatch
@ -168,7 +168,7 @@ class RestartStrategySpec extends JUnitSuite {
val boss = actorOf(new Actor{ val boss = actorOf(new Actor{
self.faultHandler = OneForOneStrategy(List(classOf[Throwable]), Some(2), None) self.faultHandler = OneForOneStrategy(List(classOf[Throwable]), Some(2), None)
protected def receive = { case _ => () } protected def receive = { case _ => () }
}).start }).start()
val restartLatch = new StandardLatch val restartLatch = new StandardLatch
val secondRestartLatch = new StandardLatch val secondRestartLatch = new StandardLatch
@ -230,7 +230,7 @@ class RestartStrategySpec extends JUnitSuite {
protected def receive = { protected def receive = {
case m:MaximumNumberOfRestartsWithinTimeRangeReached => maxNoOfRestartsLatch.open case m:MaximumNumberOfRestartsWithinTimeRangeReached => maxNoOfRestartsLatch.open
} }
}).start }).start()
val slave = actorOf(new Actor{ val slave = actorOf(new Actor{

View file

@ -40,7 +40,7 @@ class SupervisorHierarchySpec extends JUnitSuite {
self.faultHandler = OneForOneStrategy(List(classOf[Throwable]), 5, 1000) self.faultHandler = OneForOneStrategy(List(classOf[Throwable]), 5, 1000)
protected def receive = { case _ => () } protected def receive = { case _ => () }
}).start }).start()
val manager = actorOf(new CountDownActor(countDown)) val manager = actorOf(new CountDownActor(countDown))
boss.startLink(manager) boss.startLink(manager)
@ -67,7 +67,7 @@ class SupervisorHierarchySpec extends JUnitSuite {
case MaximumNumberOfRestartsWithinTimeRangeReached(_, _, _, _) => case MaximumNumberOfRestartsWithinTimeRangeReached(_, _, _, _) =>
countDown.countDown countDown.countDown
} }
}).start }).start()
boss.startLink(crasher) boss.startLink(crasher)
crasher ! Exit(crasher, new FireWorkerException("Fire the worker!")) crasher ! Exit(crasher, new FireWorkerException("Fire the worker!"))

View file

@ -23,7 +23,7 @@ class SupervisorMiscSpec extends WordSpec with MustMatchers {
case "kill" => throw new Exception("killed") case "kill" => throw new Exception("killed")
case _ => println("received unknown message") case _ => println("received unknown message")
} }
}).start }).start()
val actor2 = Actor.actorOf(new Actor { val actor2 = Actor.actorOf(new Actor {
self.dispatcher = Dispatchers.newThreadBasedDispatcher(self) self.dispatcher = Dispatchers.newThreadBasedDispatcher(self)
@ -33,7 +33,7 @@ class SupervisorMiscSpec extends WordSpec with MustMatchers {
case "kill" => throw new Exception("killed") case "kill" => throw new Exception("killed")
case _ => println("received unknown message") case _ => println("received unknown message")
} }
}).start }).start()
val actor3 = Actor.actorOf(new Actor { val actor3 = Actor.actorOf(new Actor {
self.dispatcher = Dispatchers.newExecutorBasedEventDrivenDispatcher("test").build self.dispatcher = Dispatchers.newExecutorBasedEventDrivenDispatcher("test").build
@ -43,7 +43,7 @@ class SupervisorMiscSpec extends WordSpec with MustMatchers {
case "kill" => throw new Exception("killed") case "kill" => throw new Exception("killed")
case _ => println("received unknown message") case _ => println("received unknown message")
} }
}).start }).start()
val actor4 = Actor.actorOf(new Actor { val actor4 = Actor.actorOf(new Actor {
self.dispatcher = Dispatchers.newThreadBasedDispatcher(self) self.dispatcher = Dispatchers.newThreadBasedDispatcher(self)
@ -53,7 +53,7 @@ class SupervisorMiscSpec extends WordSpec with MustMatchers {
case "kill" => throw new Exception("killed") case "kill" => throw new Exception("killed")
case _ => println("received unknown message") case _ => println("received unknown message")
} }
}).start }).start()
val sup = Supervisor( val sup = Supervisor(
SupervisorConfig( SupervisorConfig(

View file

@ -72,7 +72,7 @@ object SupervisorSpec {
// ===================================================== // =====================================================
def temporaryActorAllForOne = { def temporaryActorAllForOne = {
val temporaryActor = actorOf[TemporaryActor].start val temporaryActor = actorOf[TemporaryActor].start()
val supervisor = Supervisor( val supervisor = Supervisor(
SupervisorConfig( SupervisorConfig(
@ -86,7 +86,7 @@ object SupervisorSpec {
} }
def singleActorAllForOne = { def singleActorAllForOne = {
val pingpong = actorOf[PingPongActor].start val pingpong = actorOf[PingPongActor].start()
val supervisor = Supervisor( val supervisor = Supervisor(
SupervisorConfig( SupervisorConfig(
@ -100,7 +100,7 @@ object SupervisorSpec {
} }
def singleActorOneForOne = { def singleActorOneForOne = {
val pingpong = actorOf[PingPongActor].start val pingpong = actorOf[PingPongActor].start()
val supervisor = Supervisor( val supervisor = Supervisor(
SupervisorConfig( SupervisorConfig(
@ -114,9 +114,9 @@ object SupervisorSpec {
} }
def multipleActorsAllForOne = { def multipleActorsAllForOne = {
val pingpong1 = actorOf[PingPongActor].start val pingpong1 = actorOf[PingPongActor].start()
val pingpong2 = actorOf[PingPongActor].start val pingpong2 = actorOf[PingPongActor].start()
val pingpong3 = actorOf[PingPongActor].start val pingpong3 = actorOf[PingPongActor].start()
val supervisor = Supervisor( val supervisor = Supervisor(
SupervisorConfig( SupervisorConfig(
@ -138,9 +138,9 @@ object SupervisorSpec {
} }
def multipleActorsOneForOne = { def multipleActorsOneForOne = {
val pingpong1 = actorOf[PingPongActor].start val pingpong1 = actorOf[PingPongActor].start()
val pingpong2 = actorOf[PingPongActor].start val pingpong2 = actorOf[PingPongActor].start()
val pingpong3 = actorOf[PingPongActor].start val pingpong3 = actorOf[PingPongActor].start()
val supervisor = Supervisor( val supervisor = Supervisor(
SupervisorConfig( SupervisorConfig(
@ -209,7 +209,7 @@ class SupervisorSpec extends WordSpec with MustMatchers with BeforeAndAfterEach
"A supervisor" must { "A supervisor" must {
"not restart programmatically linked temporary actor" in { "not restart programmatically linked temporary actor" in {
val master = actorOf[Master].start val master = actorOf[Master].start()
intercept[RuntimeException] { intercept[RuntimeException] {
master !! (Die, TimeoutMillis) master !! (Die, TimeoutMillis)

View file

@ -36,9 +36,9 @@ class SupervisorTreeSpec extends WordSpec with MustMatchers {
"be able to kill the middle actor and see itself and its child restarted" in { "be able to kill the middle actor and see itself and its child restarted" in {
log = "INIT" log = "INIT"
val lastActor = actorOf(new Chainer("lastActor")).start val lastActor = actorOf(new Chainer("lastActor")).start()
val middleActor = actorOf(new Chainer("middleActor", Some(lastActor))).start val middleActor = actorOf(new Chainer("middleActor", Some(lastActor))).start()
val headActor = actorOf(new Chainer("headActor", Some(middleActor))).start val headActor = actorOf(new Chainer("headActor", Some(middleActor))).start()
middleActor ! Die middleActor ! Die
sleepFor(500 millis) sleepFor(500 millis)

View file

@ -19,7 +19,7 @@ class Ticket669Spec extends WordSpec with MustMatchers with BeforeAndAfterAll {
"A supervised actor with lifecycle PERMANENT" should { "A supervised actor with lifecycle PERMANENT" should {
"be able to reply on failure during preRestart" in { "be able to reply on failure during preRestart" in {
val latch = new CountDownLatch(1) val latch = new CountDownLatch(1)
val sender = Actor.actorOf(new Sender(latch)).start val sender = Actor.actorOf(new Sender(latch)).start()
val supervised = Actor.actorOf[Supervised] val supervised = Actor.actorOf[Supervised]
val supervisor = Supervisor(SupervisorConfig( val supervisor = Supervisor(SupervisorConfig(
@ -33,7 +33,7 @@ class Ticket669Spec extends WordSpec with MustMatchers with BeforeAndAfterAll {
"be able to reply on failure during postStop" in { "be able to reply on failure during postStop" in {
val latch = new CountDownLatch(1) val latch = new CountDownLatch(1)
val sender = Actor.actorOf(new Sender(latch)).start val sender = Actor.actorOf(new Sender(latch)).start()
val supervised = Actor.actorOf[Supervised] val supervised = Actor.actorOf[Supervised]
val supervisor = Supervisor(SupervisorConfig( val supervisor = Supervisor(SupervisorConfig(

View file

@ -202,7 +202,7 @@ abstract class ActorModelSpec extends JUnitSuite {
implicit val dispatcher = newInterceptedDispatcher implicit val dispatcher = newInterceptedDispatcher
val a = newTestActor val a = newTestActor
assertDispatcher(dispatcher)(starts = 0, stops = 0) assertDispatcher(dispatcher)(starts = 0, stops = 0)
a.start a.start()
assertDispatcher(dispatcher)(starts = 1, stops = 0) assertDispatcher(dispatcher)(starts = 1, stops = 0)
a.stop a.stop
await(dispatcher.stops.get == 1)(withinMs = dispatcher.timeoutMs * 5) await(dispatcher.stops.get == 1)(withinMs = dispatcher.timeoutMs * 5)
@ -222,7 +222,7 @@ abstract class ActorModelSpec extends JUnitSuite {
implicit val dispatcher = newInterceptedDispatcher implicit val dispatcher = newInterceptedDispatcher
val a = newTestActor val a = newTestActor
val start,oneAtATime = new CountDownLatch(1) val start,oneAtATime = new CountDownLatch(1)
a.start a.start()
a ! CountDown(start) a ! CountDown(start)
assertCountDown(start, Testing.testTime(3000), "Should process first message within 3 seconds") assertCountDown(start, Testing.testTime(3000), "Should process first message within 3 seconds")
@ -242,7 +242,7 @@ abstract class ActorModelSpec extends JUnitSuite {
implicit val dispatcher = newInterceptedDispatcher implicit val dispatcher = newInterceptedDispatcher
val a = newTestActor val a = newTestActor
val counter = new CountDownLatch(200) val counter = new CountDownLatch(200)
a.start a.start()
def start = spawn { for (i <- 1 to 20) { a ! WaitAck(1, counter) } } def start = spawn { for (i <- 1 to 20) { a ! WaitAck(1, counter) } }
for (i <- 1 to 10) { start } for (i <- 1 to 10) { start }
@ -254,13 +254,13 @@ abstract class ActorModelSpec extends JUnitSuite {
def spawn(f : => Unit) = { def spawn(f : => Unit) = {
val thread = new Thread { override def run { f } } val thread = new Thread { override def run { f } }
thread.start thread.start()
thread thread
} }
@Test def dispatcherShouldProcessMessagesInParallel: Unit = { @Test def dispatcherShouldProcessMessagesInParallel: Unit = {
implicit val dispatcher = newInterceptedDispatcher implicit val dispatcher = newInterceptedDispatcher
val a, b = newTestActor.start val a, b = newTestActor.start()
val aStart,aStop,bParallel = new CountDownLatch(1) val aStart,aStop,bParallel = new CountDownLatch(1)
a ! Meet(aStart,aStop) a ! Meet(aStart,aStop)
@ -278,7 +278,7 @@ abstract class ActorModelSpec extends JUnitSuite {
@Test def dispatcherShouldSuspendAndResumeAFailingNonSupervisedPermanentActor { @Test def dispatcherShouldSuspendAndResumeAFailingNonSupervisedPermanentActor {
implicit val dispatcher = newInterceptedDispatcher implicit val dispatcher = newInterceptedDispatcher
val a = newTestActor.start val a = newTestActor.start()
val done = new CountDownLatch(1) val done = new CountDownLatch(1)
a ! Restart a ! Restart
a ! CountDown(done) a ! CountDown(done)
@ -290,7 +290,7 @@ abstract class ActorModelSpec extends JUnitSuite {
@Test def dispatcherShouldNotProcessMessagesForASuspendedActor { @Test def dispatcherShouldNotProcessMessagesForASuspendedActor {
implicit val dispatcher = newInterceptedDispatcher implicit val dispatcher = newInterceptedDispatcher
val a = newTestActor.start val a = newTestActor.start()
val done = new CountDownLatch(1) val done = new CountDownLatch(1)
dispatcher.suspend(a) dispatcher.suspend(a)
a ! CountDown(done) a ! CountDown(done)
@ -313,7 +313,7 @@ abstract class ActorModelSpec extends JUnitSuite {
def flood(num: Int) { def flood(num: Int) {
val cachedMessage = CountDownNStop(new CountDownLatch(num)) val cachedMessage = CountDownNStop(new CountDownLatch(num))
(1 to num) foreach { (1 to num) foreach {
_ => newTestActor.start ! cachedMessage _ => newTestActor.start() ! cachedMessage
} }
assertCountDown(cachedMessage.latch, Testing.testTime(10000), "Should process " + num + " countdowns") assertCountDown(cachedMessage.latch, Testing.testTime(10000), "Should process " + num + " countdowns")
} }

View file

@ -35,28 +35,28 @@ class ExecutorBasedEventDrivenDispatcherActorSpec extends JUnitSuite {
private val unit = TimeUnit.MILLISECONDS private val unit = TimeUnit.MILLISECONDS
@Test def shouldSendOneWay = { @Test def shouldSendOneWay = {
val actor = actorOf[OneWayTestActor].start val actor = actorOf[OneWayTestActor].start()
val result = actor ! "OneWay" val result = actor ! "OneWay"
assert(OneWayTestActor.oneWay.await(1, TimeUnit.SECONDS)) assert(OneWayTestActor.oneWay.await(1, TimeUnit.SECONDS))
actor.stop actor.stop
} }
@Test def shouldSendReplySync = { @Test def shouldSendReplySync = {
val actor = actorOf[TestActor].start val actor = actorOf[TestActor].start()
val result = (actor !! ("Hello", 10000)).as[String] val result = (actor !! ("Hello", 10000)).as[String]
assert("World" === result.get) assert("World" === result.get)
actor.stop actor.stop
} }
@Test def shouldSendReplyAsync = { @Test def shouldSendReplyAsync = {
val actor = actorOf[TestActor].start val actor = actorOf[TestActor].start()
val result = actor !! "Hello" val result = actor !! "Hello"
assert("World" === result.get.asInstanceOf[String]) assert("World" === result.get.asInstanceOf[String])
actor.stop actor.stop
} }
@Test def shouldSendReceiveException = { @Test def shouldSendReceiveException = {
val actor = actorOf[TestActor].start val actor = actorOf[TestActor].start()
try { try {
actor !! "Failure" actor !! "Failure"
fail("Should have thrown an exception") fail("Should have thrown an exception")
@ -80,7 +80,7 @@ class ExecutorBasedEventDrivenDispatcherActorSpec extends JUnitSuite {
new Actor { new Actor {
self.dispatcher = throughputDispatcher self.dispatcher = throughputDispatcher
def receive = { case "sabotage" => works.set(false) } def receive = { case "sabotage" => works.set(false) }
}).start }).start()
val slowOne = actorOf( val slowOne = actorOf(
new Actor { new Actor {
@ -89,7 +89,7 @@ class ExecutorBasedEventDrivenDispatcherActorSpec extends JUnitSuite {
case "hogexecutor" => start.await case "hogexecutor" => start.await
case "ping" => if (works.get) latch.countDown case "ping" => if (works.get) latch.countDown
} }
}).start }).start()
slowOne ! "hogexecutor" slowOne ! "hogexecutor"
(1 to 100) foreach { _ => slowOne ! "ping"} (1 to 100) foreach { _ => slowOne ! "ping"}
@ -116,7 +116,7 @@ class ExecutorBasedEventDrivenDispatcherActorSpec extends JUnitSuite {
new Actor { new Actor {
self.dispatcher = throughputDispatcher self.dispatcher = throughputDispatcher
def receive = { case "ping" => if(works.get) latch.countDown; self.stop } def receive = { case "ping" => if(works.get) latch.countDown; self.stop }
}).start }).start()
val slowOne = actorOf( val slowOne = actorOf(
new Actor { new Actor {
@ -125,7 +125,7 @@ class ExecutorBasedEventDrivenDispatcherActorSpec extends JUnitSuite {
case "hogexecutor" => ready.countDown; start.await case "hogexecutor" => ready.countDown; start.await
case "ping" => works.set(false); self.stop case "ping" => works.set(false); self.stop
} }
}).start }).start()
slowOne ! "hogexecutor" slowOne ! "hogexecutor"
slowOne ! "ping" slowOne ! "ping"

View file

@ -37,8 +37,8 @@ class ExecutorBasedEventDrivenDispatcherActorsSpec extends JUnitSuite with MustM
@Test def slowActorShouldntBlockFastActor { @Test def slowActorShouldntBlockFastActor {
val sFinished = new CountDownLatch(50) val sFinished = new CountDownLatch(50)
val fFinished = new CountDownLatch(10) val fFinished = new CountDownLatch(10)
val s = actorOf(new SlowActor(sFinished)).start val s = actorOf(new SlowActor(sFinished)).start()
val f = actorOf(new FastActor(fFinished)).start val f = actorOf(new FastActor(fFinished)).start()
// send a lot of stuff to s // send a lot of stuff to s
for (i <- 1 to 50) { for (i <- 1 to 50) {

View file

@ -58,8 +58,8 @@ class ExecutorBasedEventDrivenWorkStealingDispatcherSpec extends JUnitSuite with
@Test def fastActorShouldStealWorkFromSlowActor { @Test def fastActorShouldStealWorkFromSlowActor {
val finishedCounter = new CountDownLatch(110) val finishedCounter = new CountDownLatch(110)
val slow = actorOf(new DelayableActor("slow", 50, finishedCounter)).start val slow = actorOf(new DelayableActor("slow", 50, finishedCounter)).start()
val fast = actorOf(new DelayableActor("fast", 10, finishedCounter)).start val fast = actorOf(new DelayableActor("fast", 10, finishedCounter)).start()
var sentToFast = 0 var sentToFast = 0
@ -98,9 +98,9 @@ class ExecutorBasedEventDrivenWorkStealingDispatcherSpec extends JUnitSuite with
val first = actorOf[FirstActor] val first = actorOf[FirstActor]
val second = actorOf[SecondActor] val second = actorOf[SecondActor]
first.start first.start()
intercept[IllegalActorStateException] { intercept[IllegalActorStateException] {
second.start second.start()
} }
} }
@ -108,9 +108,9 @@ class ExecutorBasedEventDrivenWorkStealingDispatcherSpec extends JUnitSuite with
val parent = actorOf[ParentActor] val parent = actorOf[ParentActor]
val child = actorOf[ChildActor] val child = actorOf[ChildActor]
parent.start parent.start()
intercept[IllegalActorStateException] { intercept[IllegalActorStateException] {
child.start child.start()
} }
} }
} }

View file

@ -38,7 +38,7 @@ class FutureSpec extends JUnitSuite {
@Test def shouldActorReplyResultThroughExplicitFuture { @Test def shouldActorReplyResultThroughExplicitFuture {
val actor = actorOf[TestActor] val actor = actorOf[TestActor]
actor.start actor.start()
val future = actor !!! "Hello" val future = actor !!! "Hello"
future.await future.await
assert(future.result.isDefined) assert(future.result.isDefined)
@ -48,7 +48,7 @@ class FutureSpec extends JUnitSuite {
@Test def shouldActorReplyExceptionThroughExplicitFuture { @Test def shouldActorReplyExceptionThroughExplicitFuture {
val actor = actorOf[TestActor] val actor = actorOf[TestActor]
actor.start actor.start()
val future = actor !!! "Failure" val future = actor !!! "Failure"
future.await future.await
assert(future.exception.isDefined) assert(future.exception.isDefined)
@ -57,8 +57,8 @@ class FutureSpec extends JUnitSuite {
} }
@Test def shouldFutureCompose { @Test def shouldFutureCompose {
val actor1 = actorOf[TestActor].start val actor1 = actorOf[TestActor].start()
val actor2 = actorOf(new Actor { def receive = { case s: String => self reply s.toUpperCase } } ).start val actor2 = actorOf(new Actor { def receive = { case s: String => self reply s.toUpperCase } } ).start()
val future1 = actor1 !!! "Hello" flatMap ((s: String) => actor2 !!! s) val future1 = actor1 !!! "Hello" flatMap ((s: String) => actor2 !!! s)
val future2 = actor1 !!! "Hello" flatMap (actor2 !!! (_: String)) val future2 = actor1 !!! "Hello" flatMap (actor2 !!! (_: String))
val future3 = actor1 !!! "Hello" flatMap (actor2 !!! (_: Int)) val future3 = actor1 !!! "Hello" flatMap (actor2 !!! (_: Int))
@ -70,8 +70,8 @@ class FutureSpec extends JUnitSuite {
} }
@Test def shouldFutureComposePatternMatch { @Test def shouldFutureComposePatternMatch {
val actor1 = actorOf[TestActor].start val actor1 = actorOf[TestActor].start()
val actor2 = actorOf(new Actor { def receive = { case s: String => self reply s.toUpperCase } } ).start val actor2 = actorOf(new Actor { def receive = { case s: String => self reply s.toUpperCase } } ).start()
val future1 = actor1 !!! "Hello" collect { case (s: String) => s } flatMap (actor2 !!! _) val future1 = actor1 !!! "Hello" collect { case (s: String) => s } flatMap (actor2 !!! _)
val future2 = actor1 !!! "Hello" collect { case (n: Int) => n } flatMap (actor2 !!! _) val future2 = actor1 !!! "Hello" collect { case (n: Int) => n } flatMap (actor2 !!! _)
assert(Some(Right("WORLD")) === future1.await.value) assert(Some(Right("WORLD")) === future1.await.value)
@ -86,7 +86,7 @@ class FutureSpec extends JUnitSuite {
case s: String => self reply s.length case s: String => self reply s.length
case i: Int => self reply (i * 2).toString case i: Int => self reply (i * 2).toString
} }
}).start }).start()
val future0 = actor !!! "Hello" val future0 = actor !!! "Hello"
@ -115,7 +115,7 @@ class FutureSpec extends JUnitSuite {
case Req(s: String) => self reply Res(s.length) case Req(s: String) => self reply Res(s.length)
case Req(i: Int) => self reply Res((i * 2).toString) case Req(i: Int) => self reply Res((i * 2).toString)
} }
}).start }).start()
val future1 = for { val future1 = for {
a <- actor !!! Req("Hello") collect { case Res(x: Int) => x } a <- actor !!! Req("Hello") collect { case Res(x: Int) => x }
@ -135,8 +135,8 @@ class FutureSpec extends JUnitSuite {
} }
@Test def shouldFutureAwaitEitherLeft = { @Test def shouldFutureAwaitEitherLeft = {
val actor1 = actorOf[TestActor].start val actor1 = actorOf[TestActor].start()
val actor2 = actorOf[TestActor].start val actor2 = actorOf[TestActor].start()
val future1 = actor1 !!! "Hello" val future1 = actor1 !!! "Hello"
val future2 = actor2 !!! "NoReply" val future2 = actor2 !!! "NoReply"
val result = Futures.awaitEither(future1, future2) val result = Futures.awaitEither(future1, future2)
@ -147,8 +147,8 @@ class FutureSpec extends JUnitSuite {
} }
@Test def shouldFutureAwaitEitherRight = { @Test def shouldFutureAwaitEitherRight = {
val actor1 = actorOf[TestActor].start val actor1 = actorOf[TestActor].start()
val actor2 = actorOf[TestActor].start val actor2 = actorOf[TestActor].start()
val future1 = actor1 !!! "NoReply" val future1 = actor1 !!! "NoReply"
val future2 = actor2 !!! "Hello" val future2 = actor2 !!! "Hello"
val result = Futures.awaitEither(future1, future2) val result = Futures.awaitEither(future1, future2)
@ -159,8 +159,8 @@ class FutureSpec extends JUnitSuite {
} }
@Test def shouldFutureAwaitOneLeft = { @Test def shouldFutureAwaitOneLeft = {
val actor1 = actorOf[TestActor].start val actor1 = actorOf[TestActor].start()
val actor2 = actorOf[TestActor].start val actor2 = actorOf[TestActor].start()
val future1 = actor1 !!! "NoReply" val future1 = actor1 !!! "NoReply"
val future2 = actor2 !!! "Hello" val future2 = actor2 !!! "Hello"
val result = Futures.awaitOne(List(future1, future2)) val result = Futures.awaitOne(List(future1, future2))
@ -171,8 +171,8 @@ class FutureSpec extends JUnitSuite {
} }
@Test def shouldFutureAwaitOneRight = { @Test def shouldFutureAwaitOneRight = {
val actor1 = actorOf[TestActor].start val actor1 = actorOf[TestActor].start()
val actor2 = actorOf[TestActor].start val actor2 = actorOf[TestActor].start()
val future1 = actor1 !!! "Hello" val future1 = actor1 !!! "Hello"
val future2 = actor2 !!! "NoReply" val future2 = actor2 !!! "NoReply"
val result = Futures.awaitOne(List(future1, future2)) val result = Futures.awaitOne(List(future1, future2))
@ -183,8 +183,8 @@ class FutureSpec extends JUnitSuite {
} }
@Test def shouldFutureAwaitAll = { @Test def shouldFutureAwaitAll = {
val actor1 = actorOf[TestActor].start val actor1 = actorOf[TestActor].start()
val actor2 = actorOf[TestActor].start val actor2 = actorOf[TestActor].start()
val future1 = actor1 !!! "Hello" val future1 = actor1 !!! "Hello"
val future2 = actor2 !!! "Hello" val future2 = actor2 !!! "Hello"
Futures.awaitAll(List(future1, future2)) Futures.awaitAll(List(future1, future2))
@ -202,7 +202,7 @@ class FutureSpec extends JUnitSuite {
@Test def shouldFuturesAwaitMapHandleNonEmptySequence { @Test def shouldFuturesAwaitMapHandleNonEmptySequence {
val latches = (1 to 3) map (_ => new StandardLatch) val latches = (1 to 3) map (_ => new StandardLatch)
val actors = latches map (latch => actorOf(new TestDelayActor(latch)).start) val actors = latches map (latch => actorOf(new TestDelayActor(latch)).start())
val futures = actors map (actor => (actor.!!![String]("Hello"))) val futures = actors map (actor => (actor.!!![String]("Hello")))
latches foreach { _.open } latches foreach { _.open }
@ -213,7 +213,7 @@ class FutureSpec extends JUnitSuite {
val actors = (1 to 10).toList map { _ => val actors = (1 to 10).toList map { _ =>
actorOf(new Actor { actorOf(new Actor {
def receive = { case (add: Int, wait: Int) => Thread.sleep(wait); self reply_? add } def receive = { case (add: Int, wait: Int) => Thread.sleep(wait); self reply_? add }
}).start }).start()
} }
def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 200 )) } def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 200 )) }
assert(Futures.fold(0)(futures)(_ + _).awaitBlocking.result.get === 45) assert(Futures.fold(0)(futures)(_ + _).awaitBlocking.result.get === 45)
@ -223,7 +223,7 @@ class FutureSpec extends JUnitSuite {
val actors = (1 to 10).toList map { _ => val actors = (1 to 10).toList map { _ =>
actorOf(new Actor { actorOf(new Actor {
def receive = { case (add: Int, wait: Int) => Thread.sleep(wait); self reply_? add } def receive = { case (add: Int, wait: Int) => Thread.sleep(wait); self reply_? add }
}).start }).start()
} }
def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 200 )) } def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 200 )) }
assert(futures.foldLeft(Future(0))((fr, fa) => for (r <- fr; a <- fa) yield (r + a)).awaitBlocking.result.get === 45) assert(futures.foldLeft(Future(0))((fr, fa) => for (r <- fr; a <- fa) yield (r + a)).awaitBlocking.result.get === 45)
@ -238,7 +238,7 @@ class FutureSpec extends JUnitSuite {
if (add == 6) throw new IllegalArgumentException("shouldFoldResultsWithException: expected") if (add == 6) throw new IllegalArgumentException("shouldFoldResultsWithException: expected")
self reply_? add self reply_? add
} }
}).start }).start()
} }
def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 100 )) } def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 100 )) }
assert(Futures.fold(0)(futures)(_ + _).awaitBlocking.exception.get.getMessage === "shouldFoldResultsWithException: expected") assert(Futures.fold(0)(futures)(_ + _).awaitBlocking.exception.get.getMessage === "shouldFoldResultsWithException: expected")
@ -252,7 +252,7 @@ class FutureSpec extends JUnitSuite {
val actors = (1 to 10).toList map { _ => val actors = (1 to 10).toList map { _ =>
actorOf(new Actor { actorOf(new Actor {
def receive = { case (add: Int, wait: Int) => Thread.sleep(wait); self reply_? add } def receive = { case (add: Int, wait: Int) => Thread.sleep(wait); self reply_? add }
}).start }).start()
} }
def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 200 )) } def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 200 )) }
assert(Futures.reduce(futures)(_ + _).awaitBlocking.result.get === 45) assert(Futures.reduce(futures)(_ + _).awaitBlocking.result.get === 45)
@ -267,7 +267,7 @@ class FutureSpec extends JUnitSuite {
if (add == 6) throw new IllegalArgumentException("shouldFoldResultsWithException: expected") if (add == 6) throw new IllegalArgumentException("shouldFoldResultsWithException: expected")
self reply_? add self reply_? add
} }
}).start }).start()
} }
def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 100 )) } def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 100 )) }
assert(Futures.reduce(futures)(_ + _).awaitBlocking.exception.get.getMessage === "shouldFoldResultsWithException: expected") assert(Futures.reduce(futures)(_ + _).awaitBlocking.exception.get.getMessage === "shouldFoldResultsWithException: expected")
@ -283,7 +283,7 @@ class FutureSpec extends JUnitSuite {
val actors = (1 to 10).toList map { _ => val actors = (1 to 10).toList map { _ =>
actorOf(new Actor { actorOf(new Actor {
def receive = { case (add: Int, wait: Boolean, latch: StandardLatch) => if (wait) latch.await; self reply_? add } def receive = { case (add: Int, wait: Boolean, latch: StandardLatch) => if (wait) latch.await; self reply_? add }
}).start }).start()
} }
def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx >= 5, latch)) } def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx >= 5, latch)) }
@ -299,7 +299,7 @@ class FutureSpec extends JUnitSuite {
@Test def receiveShouldExecuteOnComplete { @Test def receiveShouldExecuteOnComplete {
val latch = new StandardLatch val latch = new StandardLatch
val actor = actorOf[TestActor].start val actor = actorOf[TestActor].start()
actor !!! "Hello" receive { case "World" => latch.open } actor !!! "Hello" receive { case "World" => latch.open }
assert(latch.tryAwait(5, TimeUnit.SECONDS)) assert(latch.tryAwait(5, TimeUnit.SECONDS))
actor.stop actor.stop
@ -313,7 +313,7 @@ class FutureSpec extends JUnitSuite {
self reply counter self reply counter
counter += 2 counter += 2
} }
}).start }).start()
val oddFutures: List[Future[Int]] = List.fill(100)(oddActor !!! 'GetNext) val oddFutures: List[Future[Int]] = List.fill(100)(oddActor !!! 'GetNext)
assert(Futures.sequence(oddFutures).get.sum === 10000) assert(Futures.sequence(oddFutures).get.sum === 10000)

View file

@ -95,7 +95,7 @@ abstract class MailboxSpec extends
case e: Throwable => result.completeWithException(e) case e: Throwable => result.completeWithException(e)
} }
}) })
t.start t.start()
result result
} }

View file

@ -36,7 +36,7 @@ class PriorityDispatcherSpec extends WordSpec with MustMatchers {
case i: Int => acc = i :: acc case i: Int => acc = i :: acc
case 'Result => self reply_? acc case 'Result => self reply_? acc
} }
}).start }).start()
dispatcher.suspend(actor) //Make sure the actor isn't treating any messages, let it buffer the incoming messages dispatcher.suspend(actor) //Make sure the actor isn't treating any messages, let it buffer the incoming messages

View file

@ -33,28 +33,28 @@ class ThreadBasedActorSpec extends JUnitSuite {
def receive = { def receive = {
case "OneWay" => oneWay.countDown case "OneWay" => oneWay.countDown
} }
}).start }).start()
val result = actor ! "OneWay" val result = actor ! "OneWay"
assert(oneWay.await(1, TimeUnit.SECONDS)) assert(oneWay.await(1, TimeUnit.SECONDS))
actor.stop actor.stop
} }
@Test def shouldSendReplySync = { @Test def shouldSendReplySync = {
val actor = actorOf[TestActor].start val actor = actorOf[TestActor].start()
val result = (actor !! ("Hello", 10000)).as[String] val result = (actor !! ("Hello", 10000)).as[String]
assert("World" === result.get) assert("World" === result.get)
actor.stop actor.stop
} }
@Test def shouldSendReplyAsync = { @Test def shouldSendReplyAsync = {
val actor = actorOf[TestActor].start val actor = actorOf[TestActor].start()
val result = actor !! "Hello" val result = actor !! "Hello"
assert("World" === result.get.asInstanceOf[String]) assert("World" === result.get.asInstanceOf[String])
actor.stop actor.stop
} }
@Test def shouldSendReceiveException = { @Test def shouldSendReceiveException = {
val actor = actorOf[TestActor].start val actor = actorOf[TestActor].start()
try { try {
actor !! "Failure" actor !! "Failure"
fail("Should have thrown an exception") fail("Should have thrown an exception")

View file

@ -35,7 +35,7 @@ class ActorRegistrySpec extends JUnitSuite {
@Test def shouldGetActorByIdFromActorRegistry { @Test def shouldGetActorByIdFromActorRegistry {
Actor.registry.shutdownAll Actor.registry.shutdownAll
val actor = actorOf[TestActor] val actor = actorOf[TestActor]
actor.start actor.start()
val actors = Actor.registry.actorsFor("MyID") val actors = Actor.registry.actorsFor("MyID")
assert(actors.size === 1) assert(actors.size === 1)
assert(actors.head.actor.isInstanceOf[TestActor]) assert(actors.head.actor.isInstanceOf[TestActor])
@ -47,7 +47,7 @@ class ActorRegistrySpec extends JUnitSuite {
Actor.registry.shutdownAll Actor.registry.shutdownAll
val actor = actorOf[TestActor] val actor = actorOf[TestActor]
val uuid = actor.uuid val uuid = actor.uuid
actor.start actor.start()
val actorOrNone = Actor.registry.actorFor(uuid) val actorOrNone = Actor.registry.actorFor(uuid)
assert(actorOrNone.isDefined) assert(actorOrNone.isDefined)
assert(actorOrNone.get.uuid === uuid) assert(actorOrNone.get.uuid === uuid)
@ -57,7 +57,7 @@ class ActorRegistrySpec extends JUnitSuite {
@Test def shouldGetActorByClassFromActorRegistry { @Test def shouldGetActorByClassFromActorRegistry {
Actor.registry.shutdownAll Actor.registry.shutdownAll
val actor = actorOf[TestActor] val actor = actorOf[TestActor]
actor.start actor.start()
val actors = Actor.registry.actorsFor(classOf[TestActor]) val actors = Actor.registry.actorsFor(classOf[TestActor])
assert(actors.size === 1) assert(actors.size === 1)
assert(actors.head.actor.isInstanceOf[TestActor]) assert(actors.head.actor.isInstanceOf[TestActor])
@ -68,7 +68,7 @@ class ActorRegistrySpec extends JUnitSuite {
@Test def shouldGetActorByManifestFromActorRegistry { @Test def shouldGetActorByManifestFromActorRegistry {
Actor.registry.shutdownAll Actor.registry.shutdownAll
val actor = actorOf[TestActor] val actor = actorOf[TestActor]
actor.start actor.start()
val actors = Actor.registry.actorsFor[TestActor] val actors = Actor.registry.actorsFor[TestActor]
assert(actors.size === 1) assert(actors.size === 1)
assert(actors.head.actor.isInstanceOf[TestActor]) assert(actors.head.actor.isInstanceOf[TestActor])
@ -79,7 +79,7 @@ class ActorRegistrySpec extends JUnitSuite {
@Test def shouldFindThingsFromActorRegistry { @Test def shouldFindThingsFromActorRegistry {
Actor.registry.shutdownAll Actor.registry.shutdownAll
val actor = actorOf[TestActor] val actor = actorOf[TestActor]
actor.start actor.start()
val found = Actor.registry.find({ case a: ActorRef if a.actor.isInstanceOf[TestActor] => a }) val found = Actor.registry.find({ case a: ActorRef if a.actor.isInstanceOf[TestActor] => a })
assert(found.isDefined) assert(found.isDefined)
assert(found.get.actor.isInstanceOf[TestActor]) assert(found.get.actor.isInstanceOf[TestActor])
@ -90,9 +90,9 @@ class ActorRegistrySpec extends JUnitSuite {
@Test def shouldGetActorsByIdFromActorRegistry { @Test def shouldGetActorsByIdFromActorRegistry {
Actor.registry.shutdownAll Actor.registry.shutdownAll
val actor1 = actorOf[TestActor] val actor1 = actorOf[TestActor]
actor1.start actor1.start()
val actor2 = actorOf[TestActor] val actor2 = actorOf[TestActor]
actor2.start actor2.start()
val actors = Actor.registry.actorsFor("MyID") val actors = Actor.registry.actorsFor("MyID")
assert(actors.size === 2) assert(actors.size === 2)
assert(actors.head.actor.isInstanceOf[TestActor]) assert(actors.head.actor.isInstanceOf[TestActor])
@ -106,9 +106,9 @@ class ActorRegistrySpec extends JUnitSuite {
@Test def shouldGetActorsByClassFromActorRegistry { @Test def shouldGetActorsByClassFromActorRegistry {
Actor.registry.shutdownAll Actor.registry.shutdownAll
val actor1 = actorOf[TestActor] val actor1 = actorOf[TestActor]
actor1.start actor1.start()
val actor2 = actorOf[TestActor] val actor2 = actorOf[TestActor]
actor2.start actor2.start()
val actors = Actor.registry.actorsFor(classOf[TestActor]) val actors = Actor.registry.actorsFor(classOf[TestActor])
assert(actors.size === 2) assert(actors.size === 2)
assert(actors.head.actor.isInstanceOf[TestActor]) assert(actors.head.actor.isInstanceOf[TestActor])
@ -122,9 +122,9 @@ class ActorRegistrySpec extends JUnitSuite {
@Test def shouldGetActorsByManifestFromActorRegistry { @Test def shouldGetActorsByManifestFromActorRegistry {
Actor.registry.shutdownAll Actor.registry.shutdownAll
val actor1 = actorOf[TestActor] val actor1 = actorOf[TestActor]
actor1.start actor1.start()
val actor2 = actorOf[TestActor] val actor2 = actorOf[TestActor]
actor2.start actor2.start()
val actors = Actor.registry.actorsFor[TestActor] val actors = Actor.registry.actorsFor[TestActor]
assert(actors.size === 2) assert(actors.size === 2)
assert(actors.head.actor.isInstanceOf[TestActor]) assert(actors.head.actor.isInstanceOf[TestActor])
@ -139,9 +139,9 @@ class ActorRegistrySpec extends JUnitSuite {
Actor.registry.shutdownAll Actor.registry.shutdownAll
val actor1 = actorOf[TestActor] val actor1 = actorOf[TestActor]
actor1.start actor1.start()
val actor2 = actorOf[TestActor2] val actor2 = actorOf[TestActor2]
actor2.start actor2.start()
val actorsForAcotrTestActor = Actor.registry.actorsFor[TestActor] val actorsForAcotrTestActor = Actor.registry.actorsFor[TestActor]
assert(actorsForAcotrTestActor.size === 1) assert(actorsForAcotrTestActor.size === 1)
@ -166,9 +166,9 @@ class ActorRegistrySpec extends JUnitSuite {
@Test def shouldGetAllActorsFromActorRegistry { @Test def shouldGetAllActorsFromActorRegistry {
Actor.registry.shutdownAll Actor.registry.shutdownAll
val actor1 = actorOf[TestActor] val actor1 = actorOf[TestActor]
actor1.start actor1.start()
val actor2 = actorOf[TestActor] val actor2 = actorOf[TestActor]
actor2.start actor2.start()
val actors = Actor.registry.actors val actors = Actor.registry.actors
assert(actors.size === 2) assert(actors.size === 2)
assert(actors.head.actor.isInstanceOf[TestActor]) assert(actors.head.actor.isInstanceOf[TestActor])
@ -182,9 +182,9 @@ class ActorRegistrySpec extends JUnitSuite {
@Test def shouldGetResponseByAllActorsInActorRegistryWhenInvokingForeach { @Test def shouldGetResponseByAllActorsInActorRegistryWhenInvokingForeach {
Actor.registry.shutdownAll Actor.registry.shutdownAll
val actor1 = actorOf[TestActor] val actor1 = actorOf[TestActor]
actor1.start actor1.start()
val actor2 = actorOf[TestActor] val actor2 = actorOf[TestActor]
actor2.start actor2.start()
record = "" record = ""
Actor.registry.foreach(actor => actor !! "ping") Actor.registry.foreach(actor => actor !! "ping")
assert(record === "pongpong") assert(record === "pongpong")
@ -195,9 +195,9 @@ class ActorRegistrySpec extends JUnitSuite {
@Test def shouldShutdownAllActorsInActorRegistry { @Test def shouldShutdownAllActorsInActorRegistry {
Actor.registry.shutdownAll Actor.registry.shutdownAll
val actor1 = actorOf[TestActor] val actor1 = actorOf[TestActor]
actor1.start actor1.start()
val actor2 = actorOf[TestActor] val actor2 = actorOf[TestActor]
actor2.start actor2.start()
Actor.registry.shutdownAll Actor.registry.shutdownAll
assert(Actor.registry.actors.size === 0) assert(Actor.registry.actors.size === 0)
} }
@ -205,9 +205,9 @@ class ActorRegistrySpec extends JUnitSuite {
@Test def shouldRemoveUnregisterActorInActorRegistry { @Test def shouldRemoveUnregisterActorInActorRegistry {
Actor.registry.shutdownAll Actor.registry.shutdownAll
val actor1 = actorOf[TestActor] val actor1 = actorOf[TestActor]
actor1.start actor1.start()
val actor2 = actorOf[TestActor] val actor2 = actorOf[TestActor]
actor2.start actor2.start()
assert(Actor.registry.actors.size === 2) assert(Actor.registry.actors.size === 2)
Actor.registry.unregister(actor1) Actor.registry.unregister(actor1)
assert(Actor.registry.actors.size === 1) assert(Actor.registry.actors.size === 1)
@ -227,10 +227,10 @@ class ActorRegistrySpec extends JUnitSuite {
val barrier = new CyclicBarrier(3) val barrier = new CyclicBarrier(3)
def mkThread(actors: Iterable[ActorRef]) = new Thread { def mkThread(actors: Iterable[ActorRef]) = new Thread {
this.start this.start()
override def run { override def run {
barrier.await barrier.await
actors foreach { _.start } actors foreach { _.start() }
latch.countDown latch.countDown
} }
} }

View file

@ -22,7 +22,7 @@ class SchedulerSpec extends JUnitSuite {
val countDownLatch = new CountDownLatch(3) val countDownLatch = new CountDownLatch(3)
val tickActor = actorOf(new Actor { val tickActor = actorOf(new Actor {
def receive = { case Tick => countDownLatch.countDown } def receive = { case Tick => countDownLatch.countDown }
}).start }).start()
// run every 50 millisec // run every 50 millisec
Scheduler.schedule(tickActor, Tick, 0, 50, TimeUnit.MILLISECONDS) Scheduler.schedule(tickActor, Tick, 0, 50, TimeUnit.MILLISECONDS)
@ -42,7 +42,7 @@ class SchedulerSpec extends JUnitSuite {
val countDownLatch = new CountDownLatch(3) val countDownLatch = new CountDownLatch(3)
val tickActor = actorOf(new Actor { val tickActor = actorOf(new Actor {
def receive = { case Tick => countDownLatch.countDown } def receive = { case Tick => countDownLatch.countDown }
}).start }).start()
// run every 50 millisec // run every 50 millisec
Scheduler.scheduleOnce(tickActor, Tick, 50, TimeUnit.MILLISECONDS) Scheduler.scheduleOnce(tickActor, Tick, 50, TimeUnit.MILLISECONDS)
Scheduler.scheduleOnce( () => countDownLatch.countDown, 50, TimeUnit.MILLISECONDS) Scheduler.scheduleOnce( () => countDownLatch.countDown, 50, TimeUnit.MILLISECONDS)
@ -61,7 +61,7 @@ class SchedulerSpec extends JUnitSuite {
val ticks = new CountDownLatch(1000) val ticks = new CountDownLatch(1000)
val actor = actorOf(new Actor { val actor = actorOf(new Actor {
def receive = { case Ping => ticks.countDown } def receive = { case Ping => ticks.countDown }
}).start }).start()
val numActors = Actor.registry.actors.length val numActors = Actor.registry.actors.length
(1 to 1000).foreach( _ => Scheduler.scheduleOnce(actor,Ping,1,TimeUnit.MILLISECONDS) ) (1 to 1000).foreach( _ => Scheduler.scheduleOnce(actor,Ping,1,TimeUnit.MILLISECONDS) )
assert(ticks.await(10,TimeUnit.SECONDS)) assert(ticks.await(10,TimeUnit.SECONDS))
@ -77,7 +77,7 @@ class SchedulerSpec extends JUnitSuite {
val actor = actorOf(new Actor { val actor = actorOf(new Actor {
def receive = { case Ping => ticks.countDown } def receive = { case Ping => ticks.countDown }
}).start }).start()
(1 to 10).foreach { i => (1 to 10).foreach { i =>
val future = Scheduler.scheduleOnce(actor,Ping,1,TimeUnit.SECONDS) val future = Scheduler.scheduleOnce(actor,Ping,1,TimeUnit.SECONDS)

View file

@ -25,18 +25,18 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
case `testMsg1` => self.reply(3) case `testMsg1` => self.reply(3)
case `testMsg2` => self.reply(7) case `testMsg2` => self.reply(7)
} }
} ).start } ).start()
val t2 = actorOf( new Actor() { val t2 = actorOf( new Actor() {
def receive = { def receive = {
case `testMsg3` => self.reply(11) case `testMsg3` => self.reply(11)
} }
}).start }).start()
val d = dispatcherActor { val d = dispatcherActor {
case `testMsg1`|`testMsg2` => t1 case `testMsg1`|`testMsg2` => t1
case `testMsg3` => t2 case `testMsg3` => t2
}.start }.start()
val result = for { val result = for {
a <- (d !! (testMsg1, 5000)).as[Int] a <- (d !! (testMsg1, 5000)).as[Int]
@ -53,8 +53,8 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
@Test def testLogger = { @Test def testLogger = {
val msgs = new java.util.concurrent.ConcurrentSkipListSet[Any] val msgs = new java.util.concurrent.ConcurrentSkipListSet[Any]
val latch = new CountDownLatch(2) val latch = new CountDownLatch(2)
val t1 = actorOf(new Actor { def receive = { case _ => } }).start val t1 = actorOf(new Actor { def receive = { case _ => } }).start()
val l = loggerActor(t1,(x) => { msgs.add(x); latch.countDown }).start val l = loggerActor(t1,(x) => { msgs.add(x); latch.countDown }).start()
val foo : Any = "foo" val foo : Any = "foo"
val bar : Any = "bar" val bar : Any = "bar"
l ! foo l ! foo
@ -76,7 +76,7 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
t1ProcessedCount.incrementAndGet t1ProcessedCount.incrementAndGet
latch.countDown latch.countDown
} }
}).start }).start()
val t2ProcessedCount = new AtomicInteger(0) val t2ProcessedCount = new AtomicInteger(0)
val t2 = actorOf(new Actor { val t2 = actorOf(new Actor {
@ -84,7 +84,7 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
case x => t2ProcessedCount.incrementAndGet case x => t2ProcessedCount.incrementAndGet
latch.countDown latch.countDown
} }
}).start }).start()
val d = loadBalancerActor(new SmallestMailboxFirstIterator(t1 :: t2 :: Nil)) val d = loadBalancerActor(new SmallestMailboxFirstIterator(t1 :: t2 :: Nil))
for (i <- 1 to 500) d ! i for (i <- 1 to 500) d ! i
val done = latch.await(10,TimeUnit.SECONDS) val done = latch.await(10,TimeUnit.SECONDS)
@ -102,7 +102,7 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
case "foo" => gossip("bar") case "foo" => gossip("bar")
} }
}) })
i.start i.start()
def newListener = actorOf(new Actor { def newListener = actorOf(new Actor {
def receive = { def receive = {
@ -111,7 +111,7 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
latch.countDown latch.countDown
case "foo" => foreachListener.countDown case "foo" => foreachListener.countDown
} }
}).start }).start()
val a1 = newListener val a1 = newListener
val a2 = newListener val a2 = newListener
@ -142,28 +142,28 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
case `testMsg1` => self.reply(3) case `testMsg1` => self.reply(3)
case `testMsg2` => self.reply(7) case `testMsg2` => self.reply(7)
} }
} ).start } ).start()
val t2 = actorOf( new Actor() { val t2 = actorOf( new Actor() {
def receive = { def receive = {
case `testMsg1` => self.reply(3) case `testMsg1` => self.reply(3)
case `testMsg2` => self.reply(7) case `testMsg2` => self.reply(7)
} }
} ).start } ).start()
val t3 = actorOf( new Actor() { val t3 = actorOf( new Actor() {
def receive = { def receive = {
case `testMsg1` => self.reply(3) case `testMsg1` => self.reply(3)
case `testMsg2` => self.reply(7) case `testMsg2` => self.reply(7)
} }
} ).start } ).start()
val t4 = actorOf( new Actor() { val t4 = actorOf( new Actor() {
def receive = { def receive = {
case `testMsg1` => self.reply(3) case `testMsg1` => self.reply(3)
case `testMsg2` => self.reply(7) case `testMsg2` => self.reply(7)
} }
} ).start } ).start()
val d1 = loadBalancerActor(new SmallestMailboxFirstIterator(t1 :: t2 :: Nil)) val d1 = loadBalancerActor(new SmallestMailboxFirstIterator(t1 :: t2 :: Nil))
val d2 = loadBalancerActor(new CyclicIterator[ActorRef](t3 :: t4 :: Nil)) val d2 = loadBalancerActor(new CyclicIterator[ActorRef](t3 :: t4 :: Nil))
@ -213,9 +213,9 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
def receive = { def receive = {
case "success" => successes.countDown case "success" => successes.countDown
} }
}).start) }).start())
val pool = actorOf(new TestPool).start val pool = actorOf(new TestPool).start()
pool ! "a" pool ! "a"
pool ! "b" pool ! "b"
@ -253,7 +253,7 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
} }
} }
}) })
}).start }).start()
try { try {
(for(count <- 1 to 500) yield actorPool.!!![String]("Test", 20000)) foreach { (for(count <- 1 to 500) yield actorPool.!!![String]("Test", 20000)) foreach {
@ -299,7 +299,7 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
// //
// first message should create the minimum number of delgates // first message should create the minimum number of delgates
// //
val pool = actorOf(new TestPool).start val pool = actorOf(new TestPool).start()
pool ! 1 pool ! 1
(pool !! ActorPool.Stat).asInstanceOf[Option[ActorPool.Stats]].get.size must be (2) (pool !! ActorPool.Stat).asInstanceOf[Option[ActorPool.Stats]].get.size must be (2)
@ -370,7 +370,7 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
def receive = _route def receive = _route
} }
val pool = actorOf(new TestPool).start val pool = actorOf(new TestPool).start()
var loops = 0 var loops = 0
def loop(t:Int) = { def loop(t:Int) = {
@ -433,7 +433,7 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
def receive = _route def receive = _route
} }
val pool1 = actorOf(new TestPool1).start val pool1 = actorOf(new TestPool1).start()
pool1 ! "a" pool1 ! "a"
pool1 ! "b" pool1 ! "b"
var done = latch.await(1,TimeUnit.SECONDS) var done = latch.await(1,TimeUnit.SECONDS)
@ -465,7 +465,7 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
latch = new CountDownLatch(2) latch = new CountDownLatch(2)
delegates clear delegates clear
val pool2 = actorOf(new TestPool2).start val pool2 = actorOf(new TestPool2).start()
pool2 ! "a" pool2 ! "a"
pool2 ! "b" pool2 ! "b"
done = latch.await(1, TimeUnit.SECONDS) done = latch.await(1, TimeUnit.SECONDS)
@ -514,7 +514,7 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
// //
// put some pressure on the pool // put some pressure on the pool
// //
val pool = actorOf(new TestPool).start val pool = actorOf(new TestPool).start()
for (m <- 0 to 10) pool ! 250 for (m <- 0 to 10) pool ! 250
Thread.sleep(5) Thread.sleep(5)
val z = (pool !! ActorPool.Stat).asInstanceOf[Option[ActorPool.Stats]].get.size val z = (pool !! ActorPool.Stat).asInstanceOf[Option[ActorPool.Stats]].get.size

View file

@ -14,9 +14,9 @@ class CallingThreadDispatcherModelSpec extends ActorModelSpec {
def flood(num: Int) { def flood(num: Int) {
val cachedMessage = CountDownNStop(new CountDownLatch(num)) val cachedMessage = CountDownNStop(new CountDownLatch(num))
val keeper = newTestActor.start val keeper = newTestActor.start()
(1 to num) foreach { (1 to num) foreach {
_ => newTestActor.start ! cachedMessage _ => newTestActor.start() ! cachedMessage
} }
keeper.stop keeper.stop
assertCountDown(cachedMessage.latch,10000, "Should process " + num + " countdowns") assertCountDown(cachedMessage.latch,10000, "Should process " + num + " countdowns")

View file

@ -27,7 +27,7 @@ class Ticket703Spec extends WordSpec with MustMatchers {
self.reply_?("Response") self.reply_?("Response")
} }
}) })
}).start }).start()
(actorPool.!!![String]("Ping", 7000)).await.result must be === Some("Response") (actorPool.!!![String]("Ping", 7000)).await.result must be === Some("Response")
} }
} }

View file

@ -132,13 +132,13 @@ object Actor extends ListenerManagement {
* <pre> * <pre>
* import Actor._ * import Actor._
* val actor = actorOf[MyActor] * val actor = actorOf[MyActor]
* actor.start * actor.start()
* actor ! message * actor ! message
* actor.stop * actor.stop
* </pre> * </pre>
* You can create and start the actor in one statement like this: * You can create and start the actor in one statement like this:
* <pre> * <pre>
* val actor = actorOf[MyActor].start * val actor = actorOf[MyActor].start()
* </pre> * </pre>
*/ */
def actorOf[T <: Actor : Manifest]: ActorRef = actorOf(manifest[T].erasure.asInstanceOf[Class[_ <: Actor]]) def actorOf[T <: Actor : Manifest]: ActorRef = actorOf(manifest[T].erasure.asInstanceOf[Class[_ <: Actor]])
@ -148,13 +148,13 @@ object Actor extends ListenerManagement {
* <pre> * <pre>
* import Actor._ * import Actor._
* val actor = actorOf(classOf[MyActor]) * val actor = actorOf(classOf[MyActor])
* actor.start * actor.start()
* actor ! message * actor ! message
* actor.stop * actor.stop
* </pre> * </pre>
* You can create and start the actor in one statement like this: * You can create and start the actor in one statement like this:
* <pre> * <pre>
* val actor = actorOf(classOf[MyActor]).start * val actor = actorOf(classOf[MyActor]).start()
* </pre> * </pre>
*/ */
def actorOf(clazz: Class[_ <: Actor]): ActorRef = new LocalActorRef(() => { def actorOf(clazz: Class[_ <: Actor]): ActorRef = new LocalActorRef(() => {
@ -176,13 +176,13 @@ object Actor extends ListenerManagement {
* <pre> * <pre>
* import Actor._ * import Actor._
* val actor = actorOf(new MyActor) * val actor = actorOf(new MyActor)
* actor.start * actor.start()
* actor ! message * actor ! message
* actor.stop * actor.stop
* </pre> * </pre>
* You can create and start the actor in one statement like this: * You can create and start the actor in one statement like this:
* <pre> * <pre>
* val actor = actorOf(new MyActor).start * val actor = actorOf(new MyActor).start()
* </pre> * </pre>
*/ */
def actorOf(factory: => Actor): ActorRef = new LocalActorRef(() => factory, None) def actorOf(factory: => Actor): ActorRef = new LocalActorRef(() => factory, None)
@ -219,7 +219,7 @@ object Actor extends ListenerManagement {
def receive = { def receive = {
case Spawn => try { body } finally { self.stop } case Spawn => try { body } finally { self.stop }
} }
}).start ! Spawn }).start() ! Spawn
} }
/** /**
* Implicitly converts the given Option[Any] to a AnyOptionAsTypedOption which offers the method <code>as[T]</code> * Implicitly converts the given Option[Any] to a AnyOptionAsTypedOption which offers the method <code>as[T]</code>
@ -366,7 +366,7 @@ trait Actor {
/** /**
* User overridable callback. * User overridable callback.
* <p/> * <p/>
* Is called when an Actor is started by invoking 'actor.start'. * Is called when an Actor is started by invoking 'actor.start()'.
*/ */
def preStart {} def preStart {}

View file

@ -60,14 +60,14 @@ abstract class Channel[T] {
* import Actor._ * import Actor._
* *
* val actor = actorOf[MyActor] * val actor = actorOf[MyActor]
* actor.start * actor.start()
* actor ! message * actor ! message
* actor.stop * actor.stop
* </pre> * </pre>
* *
* You can also create and start actors like this: * You can also create and start actors like this:
* <pre> * <pre>
* val actor = actorOf[MyActor].start * val actor = actorOf[MyActor].start()
* </pre> * </pre>
* *
* Here is an example on how to create an actor with a non-default constructor. * Here is an example on how to create an actor with a non-default constructor.
@ -75,7 +75,7 @@ abstract class Channel[T] {
* import Actor._ * import Actor._
* *
* val actor = actorOf(new MyActor(...)) * val actor = actorOf(new MyActor(...))
* actor.start * actor.start()
* actor ! message * actor ! message
* actor.stop * actor.stop
* </pre> * </pre>
@ -761,7 +761,7 @@ class LocalActorRef private[akka] (
*/ */
def startLink(actorRef: ActorRef): Unit = guard.withGuard { def startLink(actorRef: ActorRef): Unit = guard.withGuard {
link(actorRef) link(actorRef)
actorRef.start actorRef.start()
} }
/** /**
@ -770,7 +770,7 @@ class LocalActorRef private[akka] (
* To be invoked from within the actor itself. * To be invoked from within the actor itself.
*/ */
def spawn(clazz: Class[_ <: Actor]): ActorRef = def spawn(clazz: Class[_ <: Actor]): ActorRef =
Actor.actorOf(clazz).start Actor.actorOf(clazz).start()
/** /**
* Atomically create (from actor class), start and make an actor remote. * Atomically create (from actor class), start and make an actor remote.
@ -781,7 +781,7 @@ class LocalActorRef private[akka] (
ensureRemotingEnabled ensureRemotingEnabled
val ref = Actor.remote.actorOf(clazz, hostname, port) val ref = Actor.remote.actorOf(clazz, hostname, port)
ref.timeout = timeout ref.timeout = timeout
ref.start ref.start()
} }
/** /**
@ -792,7 +792,7 @@ class LocalActorRef private[akka] (
def spawnLink(clazz: Class[_ <: Actor]): ActorRef = { def spawnLink(clazz: Class[_ <: Actor]): ActorRef = {
val actor = spawn(clazz) val actor = spawn(clazz)
link(actor) link(actor)
actor.start actor.start()
actor actor
} }
@ -806,7 +806,7 @@ class LocalActorRef private[akka] (
val actor = Actor.remote.actorOf(clazz, hostname, port) val actor = Actor.remote.actorOf(clazz, hostname, port)
actor.timeout = timeout actor.timeout = timeout
link(actor) link(actor)
actor.start actor.start()
actor actor
} }
@ -1296,7 +1296,7 @@ trait ScalaActorRef extends ActorRefShared { ref: ActorRef =>
def !(message: Any)(implicit sender: Option[ActorRef] = None): Unit = { def !(message: Any)(implicit sender: Option[ActorRef] = None): Unit = {
if (isRunning) postMessageToMailbox(message, sender) if (isRunning) postMessageToMailbox(message, sender)
else throw new ActorInitializationException( else throw new ActorInitializationException(
"Actor has not been started, you need to invoke 'actor.start' before using it") "Actor has not been started, you need to invoke 'actor.start()' before using it")
} }
/** /**
@ -1327,7 +1327,7 @@ trait ScalaActorRef extends ActorRefShared { ref: ActorRef =>
} }
future.resultOrException future.resultOrException
} else throw new ActorInitializationException( } else throw new ActorInitializationException(
"Actor has not been started, you need to invoke 'actor.start' before using it") "Actor has not been started, you need to invoke 'actor.start()' before using it")
} }
/** /**
@ -1342,7 +1342,7 @@ trait ScalaActorRef extends ActorRefShared { ref: ActorRef =>
def !!![T](message: Any, timeout: Long = this.timeout)(implicit sender: Option[ActorRef] = None): Future[T] = { def !!![T](message: Any, timeout: Long = this.timeout)(implicit sender: Option[ActorRef] = None): Future[T] = {
if (isRunning) postMessageToMailboxAndCreateFutureResultWithTimeout[T](message, timeout, sender, None) if (isRunning) postMessageToMailboxAndCreateFutureResultWithTimeout[T](message, timeout, sender, None)
else throw new ActorInitializationException( else throw new ActorInitializationException(
"Actor has not been started, you need to invoke 'actor.start' before using it") "Actor has not been started, you need to invoke 'actor.start()' before using it")
} }
/** /**
@ -1356,7 +1356,7 @@ trait ScalaActorRef extends ActorRefShared { ref: ActorRef =>
postMessageToMailboxAndCreateFutureResultWithTimeout(message, timeout, sender.get.sender, sender.get.senderFuture) postMessageToMailboxAndCreateFutureResultWithTimeout(message, timeout, sender.get.sender, sender.get.senderFuture)
else else
postMessageToMailbox(message, sender.get.sender) postMessageToMailbox(message, sender.get.sender)
} else throw new ActorInitializationException("Actor has not been started, you need to invoke 'actor.start' before using it") } else throw new ActorInitializationException("Actor has not been started, you need to invoke 'actor.start()' before using it")
} }
/** /**

View file

@ -106,7 +106,7 @@ sealed class Supervisor(handler: FaultHandlingStrategy) {
private val _childActors = new ConcurrentHashMap[String, List[ActorRef]] private val _childActors = new ConcurrentHashMap[String, List[ActorRef]]
private val _childSupervisors = new CopyOnWriteArrayList[Supervisor] private val _childSupervisors = new CopyOnWriteArrayList[Supervisor]
private[akka] val supervisor = actorOf(new SupervisorActor(handler)).start private[akka] val supervisor = actorOf(new SupervisorActor(handler)).start()
def uuid = supervisor.uuid def uuid = supervisor.uuid
@ -131,7 +131,7 @@ sealed class Supervisor(handler: FaultHandlingStrategy) {
servers.map(server => servers.map(server =>
server match { server match {
case Supervise(actorRef, lifeCycle, registerAsRemoteService) => case Supervise(actorRef, lifeCycle, registerAsRemoteService) =>
actorRef.start actorRef.start()
val className = actorRef.actor.getClass.getName val className = actorRef.actor.getClass.getName
val currentActors = { val currentActors = {
val list = _childActors.get(className) val list = _childActors.get(className)

View file

@ -86,7 +86,7 @@ abstract class UntypedActor extends Actor {
/** /**
* User overridable callback. * User overridable callback.
* <p/> * <p/>
* Is called when an Actor is started by invoking 'actor.start'. * Is called when an Actor is started by invoking 'actor.start()'.
*/ */
override def preStart {} override def preStart {}

View file

@ -40,14 +40,14 @@ object DataFlow {
* Executes the supplied function in another thread. * Executes the supplied function in another thread.
*/ */
def thread[A <: AnyRef, R <: AnyRef](body: A => R) = def thread[A <: AnyRef, R <: AnyRef](body: A => R) =
actorOf(new ReactiveEventBasedThread(body)).start actorOf(new ReactiveEventBasedThread(body)).start()
/** /**
* JavaAPI. * JavaAPI.
* Executes the supplied Function in another thread. * Executes the supplied Function in another thread.
*/ */
def thread[A <: AnyRef, R <: AnyRef](body: Function[A,R]) = def thread[A <: AnyRef, R <: AnyRef](body: Function[A,R]) =
actorOf(new ReactiveEventBasedThread(body.apply)).start actorOf(new ReactiveEventBasedThread(body.apply)).start()
private class ReactiveEventBasedThread[A <: AnyRef, T <: AnyRef](body: A => T) private class ReactiveEventBasedThread[A <: AnyRef, T <: AnyRef](body: A => T)
extends Actor { extends Actor {
@ -101,7 +101,7 @@ object DataFlow {
} }
} }
private[this] val in = actorOf(new In(this)).start private[this] val in = actorOf(new In(this)).start()
/** /**
* Sets the value of this variable (if unset) with the value of the supplied variable. * Sets the value of this variable (if unset) with the value of the supplied variable.
@ -143,7 +143,7 @@ object DataFlow {
*/ */
def apply(): T = { def apply(): T = {
value.get getOrElse { value.get getOrElse {
val out = actorOf(new Out(this)).start val out = actorOf(new Out(this)).start()
val result = try { val result = try {
blockedReaders offer out blockedReaders offer out

View file

@ -208,7 +208,7 @@ object EventHandler extends ListenerManagement {
defaultListeners foreach { listenerName => defaultListeners foreach { listenerName =>
try { try {
ReflectiveAccess.getClassFor[Actor](listenerName) map { clazz => ReflectiveAccess.getClassFor[Actor](listenerName) map { clazz =>
addListener(Actor.actorOf(clazz).start) addListener(Actor.actorOf(clazz).start())
} }
} catch { } catch {
case e: Exception => case e: Exception =>

View file

@ -137,7 +137,7 @@ case class CannotInstantiateRemoteExceptionDueToRemoteProtocolParsingErrorExcept
abstract class RemoteSupport extends ListenerManagement with RemoteServerModule with RemoteClientModule { abstract class RemoteSupport extends ListenerManagement with RemoteServerModule with RemoteClientModule {
lazy val eventHandler: ActorRef = { lazy val eventHandler: ActorRef = {
val handler = Actor.actorOf[RemoteEventHandler].start val handler = Actor.actorOf[RemoteEventHandler].start()
// add the remote client and server listener that pipes the events to the event handler system // add the remote client and server listener that pipes the events to the event handler system
addListener(handler) addListener(handler)
handler handler
@ -157,13 +157,13 @@ abstract class RemoteSupport extends ListenerManagement with RemoteServerModule
* <pre> * <pre>
* import Actor._ * import Actor._
* val actor = actorOf(classOf[MyActor],"www.akka.io", 2552) * val actor = actorOf(classOf[MyActor],"www.akka.io", 2552)
* actor.start * actor.start()
* actor ! message * actor ! message
* actor.stop * actor.stop
* </pre> * </pre>
* You can create and start the actor in one statement like this: * You can create and start the actor in one statement like this:
* <pre> * <pre>
* val actor = actorOf(classOf[MyActor],"www.akka.io", 2552).start * val actor = actorOf(classOf[MyActor],"www.akka.io", 2552).start()
* </pre> * </pre>
*/ */
@deprecated("Will be removed after 1.1") @deprecated("Will be removed after 1.1")
@ -176,13 +176,13 @@ abstract class RemoteSupport extends ListenerManagement with RemoteServerModule
* <pre> * <pre>
* import Actor._ * import Actor._
* val actor = actorOf(classOf[MyActor],"www.akka.io",2552) * val actor = actorOf(classOf[MyActor],"www.akka.io",2552)
* actor.start * actor.start()
* actor ! message * actor ! message
* actor.stop * actor.stop
* </pre> * </pre>
* You can create and start the actor in one statement like this: * You can create and start the actor in one statement like this:
* <pre> * <pre>
* val actor = actorOf(classOf[MyActor],"www.akka.io",2552).start * val actor = actorOf(classOf[MyActor],"www.akka.io",2552).start()
* </pre> * </pre>
*/ */
@deprecated("Will be removed after 1.1") @deprecated("Will be removed after 1.1")
@ -204,13 +204,13 @@ abstract class RemoteSupport extends ListenerManagement with RemoteServerModule
* <pre> * <pre>
* import Actor._ * import Actor._
* val actor = actorOf[MyActor]("www.akka.io",2552) * val actor = actorOf[MyActor]("www.akka.io",2552)
* actor.start * actor.start()
* actor ! message * actor ! message
* actor.stop * actor.stop
* </pre> * </pre>
* You can create and start the actor in one statement like this: * You can create and start the actor in one statement like this:
* <pre> * <pre>
* val actor = actorOf[MyActor]("www.akka.io",2552).start * val actor = actorOf[MyActor]("www.akka.io",2552).start()
* </pre> * </pre>
*/ */
@deprecated("Will be removed after 1.1") @deprecated("Will be removed after 1.1")

View file

@ -37,7 +37,7 @@ object Routing {
def loadBalancerActor(actors: => InfiniteIterator[ActorRef]): ActorRef = def loadBalancerActor(actors: => InfiniteIterator[ActorRef]): ActorRef =
actorOf(new Actor with LoadBalancer { actorOf(new Actor with LoadBalancer {
val seq = actors val seq = actors
}).start }).start()
/** /**
* Creates a Dispatcher given a routing and a message-transforming function. * Creates a Dispatcher given a routing and a message-transforming function.
@ -46,14 +46,14 @@ object Routing {
actorOf(new Actor with Dispatcher { actorOf(new Actor with Dispatcher {
override def transform(msg: Any) = msgTransformer(msg) override def transform(msg: Any) = msgTransformer(msg)
def routes = routing def routes = routing
}).start }).start()
/** /**
* Creates a Dispatcher given a routing. * Creates a Dispatcher given a routing.
*/ */
def dispatcherActor(routing: PF[Any, ActorRef]): ActorRef = actorOf(new Actor with Dispatcher { def dispatcherActor(routing: PF[Any, ActorRef]): ActorRef = actorOf(new Actor with Dispatcher {
def routes = routing def routes = routing
}).start }).start()
/** /**
* Creates an actor that pipes all incoming messages to * Creates an actor that pipes all incoming messages to

View file

@ -27,7 +27,7 @@ trait ListenerManagement {
* The <code>listener</code> is started by this method if manageLifeCycleOfListeners yields true. * The <code>listener</code> is started by this method if manageLifeCycleOfListeners yields true.
*/ */
def addListener(listener: ActorRef) { def addListener(listener: ActorRef) {
if (manageLifeCycleOfListeners) listener.start if (manageLifeCycleOfListeners) listener.start()
listeners add listener listeners add listener
} }

View file

@ -103,5 +103,5 @@ The above actor can be added as listener of registry events:
import akka.actor._ import akka.actor._
import akka.actor.Actor._ import akka.actor.Actor._
val listener = actorOf[RegistryListener].start val listener = actorOf[RegistryListener].start()
registry.addListener(listener) registry.addListener(listener)

View file

@ -41,7 +41,7 @@ Creating Actors
.. code-block:: scala .. code-block:: scala
val myActor = Actor.actorOf[MyActor] val myActor = Actor.actorOf[MyActor]
myActor.start myActor.start()
Normally you would want to import the ``actorOf`` method like this: Normally you would want to import the ``actorOf`` method like this:
@ -57,7 +57,7 @@ You can also start it in the same statement:
.. code-block:: scala .. code-block:: scala
val myActor = actorOf[MyActor].start val myActor = actorOf[MyActor].start()
The call to ``actorOf`` returns an instance of ``ActorRef``. This is a handle to the ``Actor`` instance which you can use to interact with the ``Actor``. The ``ActorRef`` is immutable and has a one to one relationship with the Actor it represents. The ``ActorRef`` is also serializable and network-aware. This means that you can serialize it, send it over the wire and use it on a remote host and it will still be representing the same Actor on the original node, across the network. The call to ``actorOf`` returns an instance of ``ActorRef``. This is a handle to the ``Actor`` instance which you can use to interact with the ``Actor``. The ``ActorRef`` is immutable and has a one to one relationship with the Actor it represents. The ``ActorRef`` is also serializable and network-aware. This means that you can serialize it, send it over the wire and use it on a remote host and it will still be representing the same Actor on the original node, across the network.
@ -70,7 +70,7 @@ Here is an example:
.. code-block:: scala .. code-block:: scala
val a = actorOf(new MyActor(..)).start // allows passing in arguments into the MyActor constructor val a = actorOf(new MyActor(..)).start() // allows passing in arguments into the MyActor constructor
Running a block of code asynchronously Running a block of code asynchronously
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -370,13 +370,13 @@ Actors are started by invoking the ``start`` method.
.. code-block:: scala .. code-block:: scala
val actor = actorOf[MyActor] val actor = actorOf[MyActor]
actor.start actor.start()
You can create and start the ``Actor`` in a oneliner like this: You can create and start the ``Actor`` in a oneliner like this:
.. code-block:: scala .. code-block:: scala
val actor = actorOf[MyActor].start val actor = actorOf[MyActor].start()
When you start the ``Actor`` then it will automatically call the ``def preStart`` callback method on the ``Actor`` trait. This is an excellent place to add initialization code for the actor. When you start the ``Actor`` then it will automatically call the ``def preStart`` callback method on the ``Actor`` trait. This is an excellent place to add initialization code for the actor.
@ -478,7 +478,7 @@ Here is another little cute example of ``become`` and ``unbecome`` in action:
} }
} }
val swap = actorOf[Swapper].start val swap = actorOf[Swapper].start()
swap ! Swap // prints Hi swap ! Swap // prints Hi
swap ! Swap // prints Ho swap ! Swap // prints Ho

View file

@ -336,7 +336,7 @@ Here is an example:
victimActorRef, maxNrOfRetries, withinTimeRange, lastExceptionCausingRestart) => victimActorRef, maxNrOfRetries, withinTimeRange, lastExceptionCausingRestart) =>
... // handle the error situation ... // handle the error situation
} }
}).start }).start()
You will also get this log warning similar to this: You will also get this log warning similar to this:

View file

@ -198,7 +198,7 @@ To use the Lock you can run a small program like this:
def main(args: Array[String]) { def main(args: Array[String]) {
val lock = Actor.actorOf(new Lock("1234")).start val lock = Actor.actorOf(new Lock("1234")).start()
lock ! '1' lock ! '1'
lock ! '2' lock ! '2'

View file

@ -263,7 +263,7 @@ Finally, bind the *handleHttpRequest* function of the *Endpoint* trait to the ac
def hook(uri: String): Boolean = ((uri == ProvideSameActor) || (uri == ProvideNewActor)) def hook(uri: String): Boolean = ((uri == ProvideSameActor) || (uri == ProvideNewActor))
def provide(uri: String): ActorRef = { def provide(uri: String): ActorRef = {
if (uri == ProvideSameActor) same if (uri == ProvideSameActor) same
else actorOf[BoringActor].start else actorOf[BoringActor].start()
} }
// //
@ -292,7 +292,7 @@ Finally, bind the *handleHttpRequest* function of the *Endpoint* trait to the ac
// //
// this will be our "same" actor provided with ProvideSameActor endpoint is hit // this will be our "same" actor provided with ProvideSameActor endpoint is hit
// //
lazy val same = actorOf[BoringActor].start lazy val same = actorOf[BoringActor].start()
} }
Handling requests Handling requests
@ -389,10 +389,10 @@ As noted above, hook functions are non-exclusive. This means multiple actors can
// Try with/without a header named "Test-Token" // Try with/without a header named "Test-Token"
// Try with/without a form parameter named "Data" // Try with/without a form parameter named "Data"
def hookMultiActionA(uri: String): Boolean = uri startsWith Multi def hookMultiActionA(uri: String): Boolean = uri startsWith Multi
def provideMultiActionA(uri: String): ActorRef = actorOf(new ActionAActor(complete)).start def provideMultiActionA(uri: String): ActorRef = actorOf(new ActionAActor(complete)).start()
def hookMultiActionB(uri: String): Boolean = uri startsWith Multi def hookMultiActionB(uri: String): Boolean = uri startsWith Multi
def provideMultiActionB(uri: String): ActorRef = actorOf(new ActionBActor(complete)).start def provideMultiActionB(uri: String): ActorRef = actorOf(new ActionBActor(complete)).start()
// //
// this is where you want attach your endpoint hooks // this is where you want attach your endpoint hooks
@ -421,7 +421,7 @@ As noted above, hook functions are non-exclusive. This means multiple actors can
// //
// this guy completes requests after other actions have occured // this guy completes requests after other actions have occured
// //
lazy val complete = actorOf[ActionCompleteActor].start lazy val complete = actorOf[ActionCompleteActor].start()
} }
class ActionAActor(complete:ActorRef) extends Actor { class ActionAActor(complete:ActorRef) extends Actor {

View file

@ -32,7 +32,7 @@ Here is how to start up the RemoteNode and specify the hostname and port in the
import akka.actor.Actor._ import akka.actor.Actor._
remote.start remote.start()
// Specify the classloader to use to load the remote class (actor) // Specify the classloader to use to load the remote class (actor)
remote.start(classLoader) remote.start(classLoader)
@ -593,7 +593,7 @@ So a simple listener actor can look like this:
case RemoteClientWriteFailed(request, cause, client, address) => ... // act upon write failure case RemoteClientWriteFailed(request, cause, client, address) => ... // act upon write failure
case _ => //ignore other case _ => //ignore other
} }
}).start }).start()
Registration and de-registration can be done like this: Registration and de-registration can be done like this:
@ -647,7 +647,7 @@ So a simple listener actor can look like this:
case RemoteServerClientClosed(server, clientAddress) => ... // act upon client connection close case RemoteServerClientClosed(server, clientAddress) => ... // act upon client connection close
case RemoteServerWriteFailed(request, casue, server, clientAddress) => ... // act upon server write failure case RemoteServerWriteFailed(request, casue, server, clientAddress) => ... // act upon server write failure
} }
}).start }).start()
Registration and de-registration can be done like this: Registration and de-registration can be done like this:

View file

@ -21,8 +21,8 @@ To use it you can either create a Dispatcher through the **dispatcherActor()** f
//Two actors, one named Pinger and one named Ponger //Two actors, one named Pinger and one named Ponger
//The actor(pf) method creates an anonymous actor and starts it //The actor(pf) method creates an anonymous actor and starts it
val pinger = actorOf(new Actor { def receive = { case x => println("Pinger: " + x) } }).start val pinger = actorOf(new Actor { def receive = { case x => println("Pinger: " + x) } }).start()
val ponger = actorOf(new Actor { def receive = { case x => println("Ponger: " + x) } }).start val ponger = actorOf(new Actor { def receive = { case x => println("Ponger: " + x) } }).start()
//A dispatcher that dispatches Ping messages to the pinger //A dispatcher that dispatches Ping messages to the pinger
//and Pong messages to the ponger //and Pong messages to the ponger
@ -48,8 +48,8 @@ Or by mixing in akka.patterns.Dispatcher:
class MyDispatcher extends Actor with Dispatcher { class MyDispatcher extends Actor with Dispatcher {
//Our pinger and ponger actors //Our pinger and ponger actors
val pinger = actorOf(new Actor { def receive = { case x => println("Pinger: " + x) } }).start val pinger = actorOf(new Actor { def receive = { case x => println("Pinger: " + x) } }).start()
val ponger = actorOf(new Actor { def receive = { case x => println("Ponger: " + x) } }).start val ponger = actorOf(new Actor { def receive = { case x => println("Ponger: " + x) } }).start()
//When we get a ping, we dispatch to the pinger //When we get a ping, we dispatch to the pinger
//When we get a pong, we dispatch to the ponger //When we get a pong, we dispatch to the ponger
def routes = { def routes = {
@ -59,7 +59,7 @@ Or by mixing in akka.patterns.Dispatcher:
} }
//Create an instance of our dispatcher, and start it //Create an instance of our dispatcher, and start it
val d = actorOf[MyDispatcher].start val d = actorOf[MyDispatcher].start()
d ! Ping //Prints "Pinger: Ping" d ! Ping //Prints "Pinger: Ping"
d ! Pong //Prints "Ponger: Pong" d ! Pong //Prints "Ponger: Pong"
@ -85,8 +85,8 @@ Example using the **loadBalancerActor()** factory method:
//Two actors, one named Pinger and one named Ponger //Two actors, one named Pinger and one named Ponger
//The actor(pf) method creates an anonymous actor and starts it //The actor(pf) method creates an anonymous actor and starts it
val pinger = actorOf(new Actor { def receive = { case x => println("Pinger: " + x) } }).start val pinger = actorOf(new Actor { def receive = { case x => println("Pinger: " + x) } }).start()
val ponger = actorOf(new Actor { def receive = { case x => println("Ponger: " + x) } }).start val ponger = actorOf(new Actor { def receive = { case x => println("Ponger: " + x) } }).start()
//A load balancer that given a sequence of actors dispatches them accordingly //A load balancer that given a sequence of actors dispatches them accordingly
//a CyclicIterator works in a round-robin-fashion //a CyclicIterator works in a round-robin-fashion
@ -112,14 +112,14 @@ Or by mixing in akka.routing.LoadBalancer
//A load balancer that balances between a pinger and a ponger //A load balancer that balances between a pinger and a ponger
class MyLoadBalancer extends Actor with LoadBalancer { class MyLoadBalancer extends Actor with LoadBalancer {
val pinger = actorOf(new Actor { def receive = { case x => println("Pinger: " + x) } }).start val pinger = actorOf(new Actor { def receive = { case x => println("Pinger: " + x) } }).start()
val ponger = actorOf(new Actor { def receive = { case x => println("Ponger: " + x) } }).start val ponger = actorOf(new Actor { def receive = { case x => println("Ponger: " + x) } }).start()
val seq = new CyclicIterator[ActorRef](List(pinger,ponger)) val seq = new CyclicIterator[ActorRef](List(pinger,ponger))
} }
//Create an instance of our loadbalancer, and start it //Create an instance of our loadbalancer, and start it
val d = actorOf[MyLoadBalancer].start val d = actorOf[MyLoadBalancer].start()
d ! Pong //Prints "Pinger: Pong" d ! Pong //Prints "Pinger: Pong"
d ! Pong //Prints "Ponger: Pong" d ! Pong //Prints "Ponger: Pong"

View file

@ -80,13 +80,13 @@ Step 3: Import the type class module definition and serialize / de-serialize
import akka.serialization.ActorSerialization._ import akka.serialization.ActorSerialization._
import BinaryFormatMyActor._ import BinaryFormatMyActor._
val actor1 = actorOf[MyActor].start val actor1 = actorOf[MyActor].start()
(actor1 !! "hello").getOrElse("_") should equal("world 1") (actor1 !! "hello").getOrElse("_") should equal("world 1")
(actor1 !! "hello").getOrElse("_") should equal("world 2") (actor1 !! "hello").getOrElse("_") should equal("world 2")
val bytes = toBinary(actor1) val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes) val actor2 = fromBinary(bytes)
actor2.start actor2.start()
(actor2 !! "hello").getOrElse("_") should equal("world 3") (actor2 !! "hello").getOrElse("_") should equal("world 3")
} }
@ -128,13 +128,13 @@ and use it for serialization:
import akka.serialization.ActorSerialization._ import akka.serialization.ActorSerialization._
import BinaryFormatMyStatelessActor._ import BinaryFormatMyStatelessActor._
val actor1 = actorOf[MyStatelessActor].start val actor1 = actorOf[MyStatelessActor].start()
(actor1 !! "hello").getOrElse("_") should equal("world") (actor1 !! "hello").getOrElse("_") should equal("world")
(actor1 !! "hello").getOrElse("_") should equal("world") (actor1 !! "hello").getOrElse("_") should equal("world")
val bytes = toBinary(actor1) val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes) val actor2 = fromBinary(bytes)
actor2.start actor2.start()
(actor2 !! "hello").getOrElse("_") should equal("world") (actor2 !! "hello").getOrElse("_") should equal("world")
} }
@ -182,13 +182,13 @@ and serialize / de-serialize ..
import akka.serialization.ActorSerialization._ import akka.serialization.ActorSerialization._
import BinaryFormatMyJavaSerializableActor._ import BinaryFormatMyJavaSerializableActor._
val actor1 = actorOf[MyJavaSerializableActor].start val actor1 = actorOf[MyJavaSerializableActor].start()
(actor1 !! "hello").getOrElse("_") should equal("world 1") (actor1 !! "hello").getOrElse("_") should equal("world 1")
(actor1 !! "hello").getOrElse("_") should equal("world 2") (actor1 !! "hello").getOrElse("_") should equal("world 2")
val bytes = toBinary(actor1) val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes) val actor2 = fromBinary(bytes)
actor2.start actor2.start()
(actor2 !! "hello").getOrElse("_") should equal("world 3") (actor2 !! "hello").getOrElse("_") should equal("world 3")
} }

View file

@ -348,7 +348,7 @@ Here is an example of using ``retry`` to block until an account has enough money
val account1 = Ref(100.0) val account1 = Ref(100.0)
val account2 = Ref(100.0) val account2 = Ref(100.0)
val transferer = Actor.actorOf(new Transferer).start val transferer = Actor.actorOf(new Transferer).start()
transferer ! Transfer(account1, account2, 500.0) transferer ! Transfer(account1, account2, 500.0)
// INFO Transferer: not enough money - retrying // INFO Transferer: not enough money - retrying
@ -404,7 +404,7 @@ You can also have two alternative blocking transactions, one of which can succee
val ref1 = Ref(0) val ref1 = Ref(0)
val ref2 = Ref(0) val ref2 = Ref(0)
val brancher = Actor.actorOf(new Brancher).start val brancher = Actor.actorOf(new Brancher).start()
brancher ! Branch(ref1, ref2, 1) brancher ! Branch(ref1, ref2, 1)
// INFO Brancher: not enough on left - retrying // INFO Brancher: not enough on left - retrying

View file

@ -16,14 +16,14 @@ import util.Random
*/ */
class TestKitUsageSpec extends WordSpec with BeforeAndAfterAll with ShouldMatchers with TestKit { class TestKitUsageSpec extends WordSpec with BeforeAndAfterAll with ShouldMatchers with TestKit {
val echoRef = actorOf(new EchoActor).start val echoRef = actorOf(new EchoActor).start()
val forwardRef = actorOf(new ForwardingActor(testActor)).start val forwardRef = actorOf(new ForwardingActor(testActor)).start()
val filterRef = actorOf(new FilteringActor(testActor)).start val filterRef = actorOf(new FilteringActor(testActor)).start()
val randomHead = Random.nextInt(6) val randomHead = Random.nextInt(6)
val randomTail = Random.nextInt(10) val randomTail = Random.nextInt(10)
val headList = List().padTo(randomHead, "0") val headList = List().padTo(randomHead, "0")
val tailList = List().padTo(randomTail, "1") val tailList = List().padTo(randomTail, "1")
val seqRef = actorOf(new SequencingActor(testActor, headList, tailList)).start val seqRef = actorOf(new SequencingActor(testActor, headList, tailList)).start()
override protected def afterAll(): scala.Unit = { override protected def afterAll(): scala.Unit = {
stopTestActor stopTestActor

View file

@ -58,8 +58,8 @@ Here is an example of coordinating two simple counter Actors so that they both i
} }
} }
val counter1 = Actor.actorOf[Counter].start val counter1 = Actor.actorOf[Counter].start()
val counter2 = Actor.actorOf[Counter].start val counter2 = Actor.actorOf[Counter].start()
counter1 ! Coordinated(Increment(Some(counter2))) counter1 ! Coordinated(Increment(Some(counter2)))

View file

@ -52,7 +52,7 @@ Here is a little example before we dive into a more interesting one.
} }
val myActor = Actor.actorOf[MyActor] val myActor = Actor.actorOf[MyActor]
myActor.start myActor.start()
From this call we get a handle to the 'Actor' called 'ActorRef', which we can use to interact with the Actor From this call we get a handle to the 'Actor' called 'ActorRef', which we can use to interact with the Actor
@ -260,7 +260,7 @@ The 'shutdownSessions' function simply shuts all the sessions Actors down. That
case Login(username) => case Login(username) =>
EventHandler.info(this, "User [%s] has logged in".format(username)) EventHandler.info(this, "User [%s] has logged in".format(username))
val session = actorOf(new Session(username, storage)) val session = actorOf(new Session(username, storage))
session.start session.start()
sessions += (username -> session) sessions += (username -> session)
case Logout(username) => case Logout(username) =>
@ -414,7 +414,7 @@ We have now created the full functionality for the chat server, all nicely decou
* Class encapsulating the full Chat Service. * Class encapsulating the full Chat Service.
* Start service by invoking: * Start service by invoking:
* <pre> * <pre>
* val chatService = Actor.actorOf[ChatService].start * val chatService = Actor.actorOf[ChatService].start()
* </pre> * </pre>
*/ */
class ChatService extends class ChatService extends
@ -505,7 +505,7 @@ Run a sample chat session
import sample.chat._ import sample.chat._
import akka.actor.Actor._ import akka.actor.Actor._
val chatService = actorOf[ChatService].start val chatService = actorOf[ChatService].start()
3. In the second REPL you get execute: 3. In the second REPL you get execute:

View file

@ -34,7 +34,7 @@ class BasicAuthenticatorSpec extends junit.framework.TestCase
import BasicAuthenticatorSpec._ import BasicAuthenticatorSpec._
val authenticator = actorOf[BasicAuthenticator] val authenticator = actorOf[BasicAuthenticator]
authenticator.start authenticator.start()
@Test def testChallenge = { @Test def testChallenge = {
val req = mock[ContainerRequest] val req = mock[ContainerRequest]

View file

@ -20,7 +20,7 @@ trait BootableRemoteActorService extends Bootable {
def run = Actor.remote.start(self.applicationLoader.getOrElse(null)) //Use config host/port def run = Actor.remote.start(self.applicationLoader.getOrElse(null)) //Use config host/port
}, "Akka Remote Service") }, "Akka Remote Service")
def startRemoteService = remoteServerThread.start def startRemoteService = remoteServerThread.start()
abstract override def onLoad = { abstract override def onLoad = {
if (ReflectiveAccess.isRemotingEnabled && RemoteServerSettings.isRemotingEnabled) { if (ReflectiveAccess.isRemotingEnabled && RemoteServerSettings.isRemotingEnabled) {

View file

@ -729,7 +729,7 @@ trait NettyRemoteServerModule extends RemoteServerModule { self: RemoteModule =>
private def register[Key](id: Key, actorRef: ActorRef, registry: ConcurrentHashMap[Key, ActorRef]) { private def register[Key](id: Key, actorRef: ActorRef, registry: ConcurrentHashMap[Key, ActorRef]) {
if (_isRunning.isOn) { if (_isRunning.isOn) {
registry.put(id, actorRef) //TODO change to putIfAbsent registry.put(id, actorRef) //TODO change to putIfAbsent
if (!actorRef.isRunning) actorRef.start if (!actorRef.isRunning) actorRef.start()
} }
} }
@ -1124,7 +1124,7 @@ class RemoteServerHandler(
val actorRef = factory() val actorRef = factory()
actorRef.uuid = parseUuid(uuid) //FIXME is this sensible? actorRef.uuid = parseUuid(uuid) //FIXME is this sensible?
sessionActors.get(channel).put(id, actorRef) sessionActors.get(channel).put(id, actorRef)
actorRef.start //Start it where's it's created actorRef.start() //Start it where's it's created
} }
case sessionActor => sessionActor case sessionActor => sessionActor
} }
@ -1148,7 +1148,7 @@ class RemoteServerHandler(
actorRef.id = id actorRef.id = id
actorRef.timeout = timeout actorRef.timeout = timeout
server.actorsByUuid.put(actorRef.uuid.toString, actorRef) // register by uuid server.actorsByUuid.put(actorRef.uuid.toString, actorRef) // register by uuid
actorRef.start //Start it where it's created actorRef.start() //Start it where it's created
} catch { } catch {
case e: Throwable => case e: Throwable =>
EventHandler.error(e, this, e.getMessage) EventHandler.error(e, this, e.getMessage)

View file

@ -58,7 +58,7 @@ class AkkaRemoteTest extends
/* Utilities */ /* Utilities */
def replyHandler(latch: CountDownLatch, expect: String) = Some(Actor.actorOf(new ReplyHandlerActor(latch, expect)).start) def replyHandler(latch: CountDownLatch, expect: String) = Some(Actor.actorOf(new ReplyHandlerActor(latch, expect)).start())
} }
trait NetworkFailureTest { self: WordSpec => trait NetworkFailureTest { self: WordSpec =>

View file

@ -75,7 +75,7 @@ class MyActorCustomConstructor extends Actor {
class ClientInitiatedRemoteActorSpec extends AkkaRemoteTest { class ClientInitiatedRemoteActorSpec extends AkkaRemoteTest {
"ClientInitiatedRemoteActor" should { "ClientInitiatedRemoteActor" should {
"shouldSendOneWay" in { "shouldSendOneWay" in {
val clientManaged = remote.actorOf[RemoteActorSpecActorUnidirectional](host,port).start val clientManaged = remote.actorOf[RemoteActorSpecActorUnidirectional](host,port).start()
clientManaged must not be null clientManaged must not be null
clientManaged.getClass must be (classOf[LocalActorRef]) clientManaged.getClass must be (classOf[LocalActorRef])
clientManaged ! "OneWay" clientManaged ! "OneWay"
@ -85,8 +85,8 @@ class ClientInitiatedRemoteActorSpec extends AkkaRemoteTest {
"shouldSendOneWayAndReceiveReply" in { "shouldSendOneWayAndReceiveReply" in {
val latch = new CountDownLatch(1) val latch = new CountDownLatch(1)
val actor = remote.actorOf[SendOneWayAndReplyReceiverActor](host,port).start val actor = remote.actorOf[SendOneWayAndReplyReceiverActor](host,port).start()
implicit val sender = Some(actorOf(new CountDownActor(latch)).start) implicit val sender = Some(actorOf(new CountDownActor(latch)).start())
actor ! "Hello" actor ! "Hello"
@ -94,14 +94,14 @@ class ClientInitiatedRemoteActorSpec extends AkkaRemoteTest {
} }
"shouldSendBangBangMessageAndReceiveReply" in { "shouldSendBangBangMessageAndReceiveReply" in {
val actor = remote.actorOf[RemoteActorSpecActorBidirectional](host,port).start val actor = remote.actorOf[RemoteActorSpecActorBidirectional](host,port).start()
val result = actor !! ("Hello", 10000) val result = actor !! ("Hello", 10000)
"World" must equal (result.get.asInstanceOf[String]) "World" must equal (result.get.asInstanceOf[String])
actor.stop actor.stop
} }
"shouldSendBangBangMessageAndReceiveReplyConcurrently" in { "shouldSendBangBangMessageAndReceiveReplyConcurrently" in {
val actors = (1 to 10).map(num => { remote.actorOf[RemoteActorSpecActorBidirectional](host,port).start }).toList val actors = (1 to 10).map(num => { remote.actorOf[RemoteActorSpecActorBidirectional](host,port).start() }).toList
actors.map(_ !!! ("Hello", 10000)) foreach { future => actors.map(_ !!! ("Hello", 10000)) foreach { future =>
"World" must equal (future.await.result.asInstanceOf[Option[String]].get) "World" must equal (future.await.result.asInstanceOf[Option[String]].get)
} }
@ -109,8 +109,8 @@ class ClientInitiatedRemoteActorSpec extends AkkaRemoteTest {
} }
"shouldRegisterActorByUuid" in { "shouldRegisterActorByUuid" in {
val actor1 = remote.actorOf[MyActorCustomConstructor](host, port).start val actor1 = remote.actorOf[MyActorCustomConstructor](host, port).start()
val actor2 = remote.actorOf[MyActorCustomConstructor](host, port).start val actor2 = remote.actorOf[MyActorCustomConstructor](host, port).start()
actor1 ! "incrPrefix" actor1 ! "incrPrefix"
@ -128,7 +128,7 @@ class ClientInitiatedRemoteActorSpec extends AkkaRemoteTest {
"shouldSendAndReceiveRemoteException" in { "shouldSendAndReceiveRemoteException" in {
val actor = remote.actorOf[RemoteActorSpecActorBidirectional](host, port).start val actor = remote.actorOf[RemoteActorSpecActorBidirectional](host, port).start()
try { try {
implicit val timeout = 500000000L implicit val timeout = 500000000L
val f = (actor !!! "Failure").await.resultOrException val f = (actor !!! "Failure").await.resultOrException

View file

@ -14,7 +14,7 @@ class OptimizedLocalScopedSpec extends AkkaRemoteTest {
"An enabled optimized local scoped remote" should { "An enabled optimized local scoped remote" should {
"Fetch local actor ref when scope is local" in { "Fetch local actor ref when scope is local" in {
val fooActor = Actor.actorOf[TestActor].start val fooActor = Actor.actorOf[TestActor].start()
remote.register("foo", fooActor) remote.register("foo", fooActor)
remote.actorFor("foo", host, port) must be (fooActor) remote.actorFor("foo", host, port) must be (fooActor)

View file

@ -109,7 +109,7 @@ class RemoteErrorHandlingNetworkTest extends AkkaRemoteTest with NetworkFailureT
val actor = remote.actorFor( val actor = remote.actorFor(
"akka.actor.remote.ServerInitiatedRemoteActorSpec$RemoteActorSpecActorBidirectional", timeout, host, port) "akka.actor.remote.ServerInitiatedRemoteActorSpec$RemoteActorSpecActorBidirectional", timeout, host, port)
val latch = new CountDownLatch(1) val latch = new CountDownLatch(1)
val sender = actorOf( new RemoteActorSpecActorAsyncSender(latch) ).start val sender = actorOf( new RemoteActorSpecActorAsyncSender(latch) ).start()
sender ! Send(actor) sender ! Send(actor)
latch.await(1, TimeUnit.SECONDS) must be (true) latch.await(1, TimeUnit.SECONDS) must be (true)
} }

View file

@ -226,7 +226,7 @@ class RemoteSupervisorSpec extends AkkaRemoteTest {
// Then create a concrete container in which we mix in support for the specific // Then create a concrete container in which we mix in support for the specific
// implementation of the Actors we want to use. // implementation of the Actors we want to use.
pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start()
val factory = SupervisorFactory( val factory = SupervisorFactory(
SupervisorConfig( SupervisorConfig(
@ -240,7 +240,7 @@ class RemoteSupervisorSpec extends AkkaRemoteTest {
} }
def getSingleActorOneForOneSupervisor: Supervisor = { def getSingleActorOneForOneSupervisor: Supervisor = {
pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start()
val factory = SupervisorFactory( val factory = SupervisorFactory(
SupervisorConfig( SupervisorConfig(
@ -253,9 +253,9 @@ class RemoteSupervisorSpec extends AkkaRemoteTest {
} }
def getMultipleActorsAllForOneConf: Supervisor = { def getMultipleActorsAllForOneConf: Supervisor = {
pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start()
pingpong2 = remote.actorOf[RemotePingPong2Actor](host,port).start pingpong2 = remote.actorOf[RemotePingPong2Actor](host,port).start()
pingpong3 = remote.actorOf[RemotePingPong3Actor](host,port).start pingpong3 = remote.actorOf[RemotePingPong3Actor](host,port).start()
val factory = SupervisorFactory( val factory = SupervisorFactory(
SupervisorConfig( SupervisorConfig(
@ -276,9 +276,9 @@ class RemoteSupervisorSpec extends AkkaRemoteTest {
} }
def getMultipleActorsOneForOneConf: Supervisor = { def getMultipleActorsOneForOneConf: Supervisor = {
pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start()
pingpong2 = remote.actorOf[RemotePingPong2Actor](host,port).start pingpong2 = remote.actorOf[RemotePingPong2Actor](host,port).start()
pingpong3 = remote.actorOf[RemotePingPong3Actor](host,port).start pingpong3 = remote.actorOf[RemotePingPong3Actor](host,port).start()
val factory = SupervisorFactory( val factory = SupervisorFactory(
SupervisorConfig( SupervisorConfig(
@ -299,9 +299,9 @@ class RemoteSupervisorSpec extends AkkaRemoteTest {
} }
def getNestedSupervisorsAllForOneConf: Supervisor = { def getNestedSupervisorsAllForOneConf: Supervisor = {
pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start()
pingpong2 = remote.actorOf[RemotePingPong2Actor](host,port).start pingpong2 = remote.actorOf[RemotePingPong2Actor](host,port).start()
pingpong3 = remote.actorOf[RemotePingPong3Actor](host,port).start pingpong3 = remote.actorOf[RemotePingPong3Actor](host,port).start()
val factory = SupervisorFactory( val factory = SupervisorFactory(
SupervisorConfig( SupervisorConfig(

View file

@ -25,7 +25,7 @@ Have fun.
*************************************/ *************************************/
class HelloWorldActor extends Actor { class HelloWorldActor extends Actor {
self.start self.start()
def receive = { def receive = {
case "Hello" => self.reply("World") case "Hello" => self.reply("World")

View file

@ -73,7 +73,7 @@ class ServerInitiatedRemoteActorSpec extends AkkaRemoteTest {
val actor = remote.actorFor( val actor = remote.actorFor(
"akka.actor.remote.ServerInitiatedRemoteActorSpec$RemoteActorSpecActorBidirectional", timeout,host, port) "akka.actor.remote.ServerInitiatedRemoteActorSpec$RemoteActorSpecActorBidirectional", timeout,host, port)
val latch = new CountDownLatch(1) val latch = new CountDownLatch(1)
val sender = actorOf( new RemoteActorSpecActorAsyncSender(latch) ).start val sender = actorOf( new RemoteActorSpecActorAsyncSender(latch) ).start()
sender ! Send(actor) sender ! Send(actor)
latch.await(1, TimeUnit.SECONDS) must be (true) latch.await(1, TimeUnit.SECONDS) must be (true)
} }
@ -163,7 +163,7 @@ class ServerInitiatedRemoteActorSpec extends AkkaRemoteTest {
val actor1 = actorOf[RemoteActorSpecActorUnidirectional] val actor1 = actorOf[RemoteActorSpecActorUnidirectional]
remote.register("foo", actor1) remote.register("foo", actor1)
val latch = new CountDownLatch(1) val latch = new CountDownLatch(1)
val actor2 = actorOf(new Actor { def receive = { case "Pong" => latch.countDown } }).start val actor2 = actorOf(new Actor { def receive = { case "Pong" => latch.countDown } }).start()
val remoteActor = remote.actorFor("foo", host, port) val remoteActor = remote.actorFor("foo", host, port)
remoteActor.!("Ping")(Some(actor2)) remoteActor.!("Ping")(Some(actor2))

View file

@ -13,7 +13,7 @@ class UnOptimizedLocalScopedSpec extends AkkaRemoteTest {
"An enabled optimized local scoped remote" should { "An enabled optimized local scoped remote" should {
"Fetch remote actor ref when scope is local" in { "Fetch remote actor ref when scope is local" in {
val fooActor = Actor.actorOf[TestActor].start val fooActor = Actor.actorOf[TestActor].start()
remote.register("foo", fooActor) remote.register("foo", fooActor)
remote.actorFor("foo", host, port) must not be (fooActor) remote.actorFor("foo", host, port) must not be (fooActor)

View file

@ -66,52 +66,52 @@ class SerializableTypeClassActorSpec extends
it("should be able to serialize and de-serialize a stateful actor") { it("should be able to serialize and de-serialize a stateful actor") {
import BinaryFormatMyActor._ import BinaryFormatMyActor._
val actor1 = actorOf[MyActor].start val actor1 = actorOf[MyActor].start()
(actor1 !! "hello").getOrElse("_") should equal("world 1") (actor1 !! "hello").getOrElse("_") should equal("world 1")
(actor1 !! "hello").getOrElse("_") should equal("world 2") (actor1 !! "hello").getOrElse("_") should equal("world 2")
val bytes = toBinary(actor1) val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes) val actor2 = fromBinary(bytes)
actor2.start actor2.start()
(actor2 !! "hello").getOrElse("_") should equal("world 3") (actor2 !! "hello").getOrElse("_") should equal("world 3")
} }
it("should be able to serialize and de-serialize a stateful actor with compound state") { it("should be able to serialize and de-serialize a stateful actor with compound state") {
import BinaryFormatMyActorWithDualCounter._ import BinaryFormatMyActorWithDualCounter._
val actor1 = actorOf[MyActorWithDualCounter].start val actor1 = actorOf[MyActorWithDualCounter].start()
(actor1 !! "hello").getOrElse("_") should equal("world 1 1") (actor1 !! "hello").getOrElse("_") should equal("world 1 1")
(actor1 !! "hello").getOrElse("_") should equal("world 2 2") (actor1 !! "hello").getOrElse("_") should equal("world 2 2")
val bytes = toBinary(actor1) val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes) val actor2 = fromBinary(bytes)
actor2.start actor2.start()
(actor2 !! "hello").getOrElse("_") should equal("world 3 3") (actor2 !! "hello").getOrElse("_") should equal("world 3 3")
} }
it("should be able to serialize and de-serialize a stateless actor") { it("should be able to serialize and de-serialize a stateless actor") {
import BinaryFormatMyStatelessActor._ import BinaryFormatMyStatelessActor._
val actor1 = actorOf[MyStatelessActor].start val actor1 = actorOf[MyStatelessActor].start()
(actor1 !! "hello").getOrElse("_") should equal("world") (actor1 !! "hello").getOrElse("_") should equal("world")
(actor1 !! "hello").getOrElse("_") should equal("world") (actor1 !! "hello").getOrElse("_") should equal("world")
val bytes = toBinary(actor1) val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes) val actor2 = fromBinary(bytes)
actor2.start actor2.start()
(actor2 !! "hello").getOrElse("_") should equal("world") (actor2 !! "hello").getOrElse("_") should equal("world")
} }
it("should be able to serialize and de-serialize a stateful actor with a given serializer") { it("should be able to serialize and de-serialize a stateful actor with a given serializer") {
import BinaryFormatMyJavaSerializableActor._ import BinaryFormatMyJavaSerializableActor._
val actor1 = actorOf[MyJavaSerializableActor].start val actor1 = actorOf[MyJavaSerializableActor].start()
(actor1 !! "hello").getOrElse("_") should equal("world 1") (actor1 !! "hello").getOrElse("_") should equal("world 1")
(actor1 !! "hello").getOrElse("_") should equal("world 2") (actor1 !! "hello").getOrElse("_") should equal("world 2")
val bytes = toBinary(actor1) val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes) val actor2 = fromBinary(bytes)
actor2.start actor2.start()
(actor2 !! "hello").getOrElse("_") should equal("world 3") (actor2 !! "hello").getOrElse("_") should equal("world 3")
actor2.receiveTimeout should equal (Some(1000)) actor2.receiveTimeout should equal (Some(1000))
@ -122,7 +122,7 @@ class SerializableTypeClassActorSpec extends
it("should be able to serialize and deserialize a MyStatelessActorWithMessagesInMailbox") { it("should be able to serialize and deserialize a MyStatelessActorWithMessagesInMailbox") {
import BinaryFormatMyStatelessActorWithMessagesInMailbox._ import BinaryFormatMyStatelessActorWithMessagesInMailbox._
val actor1 = actorOf[MyStatelessActorWithMessagesInMailbox].start val actor1 = actorOf[MyStatelessActorWithMessagesInMailbox].start()
(actor1 ! "hello") (actor1 ! "hello")
(actor1 ! "hello") (actor1 ! "hello")
(actor1 ! "hello") (actor1 ! "hello")
@ -147,7 +147,7 @@ class SerializableTypeClassActorSpec extends
it("should be able to serialize and de-serialize an Actor hotswapped with 'become'") { it("should be able to serialize and de-serialize an Actor hotswapped with 'become'") {
import BinaryFormatMyActor._ import BinaryFormatMyActor._
val actor1 = actorOf[MyActor].start val actor1 = actorOf[MyActor].start()
(actor1 !! "hello").getOrElse("_") should equal("world 1") (actor1 !! "hello").getOrElse("_") should equal("world 1")
(actor1 !! "hello").getOrElse("_") should equal("world 2") (actor1 !! "hello").getOrElse("_") should equal("world 2")
actor1 ! "swap" actor1 ! "swap"
@ -155,7 +155,7 @@ class SerializableTypeClassActorSpec extends
val bytes = toBinary(actor1) val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes) val actor2 = fromBinary(bytes)
actor2.start actor2.start()
(actor1 !! "hello").getOrElse("_") should equal("swapped") (actor1 !! "hello").getOrElse("_") should equal("swapped")
@ -166,7 +166,7 @@ class SerializableTypeClassActorSpec extends
it("should be able to serialize and de-serialize an hotswapped actor") { it("should be able to serialize and de-serialize an hotswapped actor") {
import BinaryFormatMyActor._ import BinaryFormatMyActor._
val actor1 = actorOf[MyActor].start val actor1 = actorOf[MyActor].start()
(actor1 !! "hello").getOrElse("_") should equal("world 1") (actor1 !! "hello").getOrElse("_") should equal("world 1")
(actor1 !! "hello").getOrElse("_") should equal("world 2") (actor1 !! "hello").getOrElse("_") should equal("world 2")
actor1 ! HotSwap { actor1 ! HotSwap {
@ -177,7 +177,7 @@ class SerializableTypeClassActorSpec extends
val bytes = toBinary(actor1) val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes) val actor2 = fromBinary(bytes)
actor2.start actor2.start()
(actor1 !! "hello").getOrElse("_") should equal("swapped") (actor1 !! "hello").getOrElse("_") should equal("swapped")
@ -190,7 +190,7 @@ class SerializableTypeClassActorSpec extends
it("should serialize and de-serialize") { it("should serialize and de-serialize") {
import BinaryFormatMyActorWithSerializableMessages._ import BinaryFormatMyActorWithSerializableMessages._
val actor1 = actorOf[MyActorWithSerializableMessages].start val actor1 = actorOf[MyActorWithSerializableMessages].start()
(actor1 ! MyMessage("hello1", ("akka", 100))) (actor1 ! MyMessage("hello1", ("akka", 100)))
(actor1 ! MyMessage("hello2", ("akka", 200))) (actor1 ! MyMessage("hello2", ("akka", 200)))
(actor1 ! MyMessage("hello3", ("akka", 300))) (actor1 ! MyMessage("hello3", ("akka", 300)))

View file

@ -39,7 +39,7 @@ class Ticket435Spec extends
it("should be able to serialize and deserialize a stateless actor with messages in mailbox") { it("should be able to serialize and deserialize a stateless actor with messages in mailbox") {
import BinaryFormatMyStatelessActorWithMessagesInMailbox._ import BinaryFormatMyStatelessActorWithMessagesInMailbox._
val actor1 = actorOf[MyStatelessActorWithMessagesInMailbox].start val actor1 = actorOf[MyStatelessActorWithMessagesInMailbox].start()
(actor1 ! "hello") (actor1 ! "hello")
(actor1 ! "hello") (actor1 ! "hello")
(actor1 ! "hello") (actor1 ! "hello")
@ -65,7 +65,7 @@ class Ticket435Spec extends
it("should serialize the mailbox optionally") { it("should serialize the mailbox optionally") {
import BinaryFormatMyStatelessActorWithMessagesInMailbox._ import BinaryFormatMyStatelessActorWithMessagesInMailbox._
val actor1 = actorOf[MyStatelessActorWithMessagesInMailbox].start val actor1 = actorOf[MyStatelessActorWithMessagesInMailbox].start()
(actor1 ! "hello") (actor1 ! "hello")
(actor1 ! "hello") (actor1 ! "hello")
(actor1 ! "hello") (actor1 ! "hello")
@ -87,7 +87,7 @@ class Ticket435Spec extends
it("should be able to serialize and deserialize a stateful actor with messages in mailbox") { it("should be able to serialize and deserialize a stateful actor with messages in mailbox") {
import BinaryFormatMyStatefulActor._ import BinaryFormatMyStatefulActor._
val actor1 = actorOf[MyStatefulActor].start val actor1 = actorOf[MyStatefulActor].start()
(actor1 ! "hi") (actor1 ! "hi")
(actor1 ! "hi") (actor1 ! "hi")
(actor1 ! "hi") (actor1 ! "hi")

View file

@ -43,37 +43,37 @@ class UntypedActorSerializationSpec extends
describe("Serializable untyped actor") { describe("Serializable untyped actor") {
it("should be able to serialize and de-serialize a stateful untyped actor") { it("should be able to serialize and de-serialize a stateful untyped actor") {
val actor1 = Actors.actorOf(classOf[MyUntypedActor]).start val actor1 = Actors.actorOf(classOf[MyUntypedActor]).start()
actor1.sendRequestReply("hello") should equal("world 1") actor1.sendRequestReply("hello") should equal("world 1")
actor1.sendRequestReply("debasish") should equal("hello debasish 2") actor1.sendRequestReply("debasish") should equal("hello debasish 2")
val f = new MyUntypedActorFormat val f = new MyUntypedActorFormat
val bytes = toBinaryJ(actor1, f) val bytes = toBinaryJ(actor1, f)
val actor2 = fromBinaryJ(bytes, f) val actor2 = fromBinaryJ(bytes, f)
actor2.start actor2.start()
actor2.sendRequestReply("hello") should equal("world 3") actor2.sendRequestReply("hello") should equal("world 3")
} }
it("should be able to serialize and de-serialize a stateful actor with compound state") { it("should be able to serialize and de-serialize a stateful actor with compound state") {
val actor1 = actorOf[MyUntypedActorWithDualCounter].start val actor1 = actorOf[MyUntypedActorWithDualCounter].start()
actor1.sendRequestReply("hello") should equal("world 1 1") actor1.sendRequestReply("hello") should equal("world 1 1")
actor1.sendRequestReply("hello") should equal("world 2 2") actor1.sendRequestReply("hello") should equal("world 2 2")
val f = new MyUntypedActorWithDualCounterFormat val f = new MyUntypedActorWithDualCounterFormat
val bytes = toBinaryJ(actor1, f) val bytes = toBinaryJ(actor1, f)
val actor2 = fromBinaryJ(bytes, f) val actor2 = fromBinaryJ(bytes, f)
actor2.start actor2.start()
actor2.sendRequestReply("hello") should equal("world 3 3") actor2.sendRequestReply("hello") should equal("world 3 3")
} }
it("should be able to serialize and de-serialize a stateless actor") { it("should be able to serialize and de-serialize a stateless actor") {
val actor1 = actorOf[MyUntypedStatelessActor].start val actor1 = actorOf[MyUntypedStatelessActor].start()
actor1.sendRequestReply("hello") should equal("world") actor1.sendRequestReply("hello") should equal("world")
actor1.sendRequestReply("hello") should equal("world") actor1.sendRequestReply("hello") should equal("world")
val bytes = toBinaryJ(actor1, MyUntypedStatelessActorFormat) val bytes = toBinaryJ(actor1, MyUntypedStatelessActorFormat)
val actor2 = fromBinaryJ(bytes, MyUntypedStatelessActorFormat) val actor2 = fromBinaryJ(bytes, MyUntypedStatelessActorFormat)
actor2.start actor2.start()
actor2.sendRequestReply("hello") should equal("world") actor2.sendRequestReply("hello") should equal("world")
} }
} }

View file

@ -65,7 +65,7 @@ object World {
val homeOff = Dim / 4 val homeOff = Dim / 4
lazy val places = Vector.fill(Dim, Dim)(new Place) lazy val places = Vector.fill(Dim, Dim)(new Place)
lazy val ants = setup lazy val ants = setup
lazy val evaporator = actorOf[Evaporator].start lazy val evaporator = actorOf[Evaporator].start()
private val snapshotFactory = TransactionFactory(readonly = true, familyName = "snapshot") private val snapshotFactory = TransactionFactory(readonly = true, familyName = "snapshot")
@ -81,7 +81,7 @@ object World {
for (x <- homeRange; y <- homeRange) yield { for (x <- homeRange; y <- homeRange) yield {
place(x, y).makeHome place(x, y).makeHome
place(x, y) enter Ant(randomInt(8)) place(x, y) enter Ant(randomInt(8))
actorOf(new AntActor(x, y)).start actorOf(new AntActor(x, y)).start()
} }
} }

View file

@ -9,7 +9,7 @@ How to run the sample:
2. In the first REPL you get execute: 2. In the first REPL you get execute:
- scala> import sample.chat._ - scala> import sample.chat._
- scala> import akka.actor.Actor._ - scala> import akka.actor.Actor._
- scala> val chatService = actorOf[ChatService].start - scala> val chatService = actorOf[ChatService].start()
3. In the second REPL you get execute: 3. In the second REPL you get execute:
- scala> import sample.chat._ - scala> import sample.chat._
- scala> ClientRunner.run - scala> ClientRunner.run

View file

@ -24,7 +24,7 @@
2. In the first REPL you get execute: 2. In the first REPL you get execute:
- scala> import sample.chat._ - scala> import sample.chat._
- scala> import akka.actor.Actor._ - scala> import akka.actor.Actor._
- scala> val chatService = actorOf[ChatService].start - scala> val chatService = actorOf[ChatService].start()
3. In the second REPL you get execute: 3. In the second REPL you get execute:
- scala> import sample.chat._ - scala> import sample.chat._
- scala> ClientRunner.run - scala> ClientRunner.run
@ -125,7 +125,7 @@
case Login(username) => case Login(username) =>
EventHandler.info(this, "User [%s] has logged in".format(username)) EventHandler.info(this, "User [%s] has logged in".format(username))
val session = actorOf(new Session(username, storage)) val session = actorOf(new Session(username, storage))
session.start session.start()
sessions += (username -> session) sessions += (username -> session)
case Logout(username) => case Logout(username) =>
@ -198,7 +198,7 @@
* Class encapsulating the full Chat Service. * Class encapsulating the full Chat Service.
* Start service by invoking: * Start service by invoking:
* <pre> * <pre>
* val chatService = Actor.actorOf[ChatService].start * val chatService = Actor.actorOf[ChatService].start()
* </pre> * </pre>
*/ */
class ChatService extends class ChatService extends
@ -220,7 +220,7 @@
def main(args: Array[String]): Unit = ServerRunner.run def main(args: Array[String]): Unit = ServerRunner.run
def run = { def run = {
actorOf[ChatService].start actorOf[ChatService].start()
} }
} }

View file

@ -127,11 +127,11 @@ class Hakker(name: String,left: ActorRef, right: ActorRef) extends Actor {
object DiningHakkers { object DiningHakkers {
def run { def run {
//Create 5 chopsticks //Create 5 chopsticks
val chopsticks = for(i <- 1 to 5) yield actorOf(new Chopstick("Chopstick "+i)).start val chopsticks = for(i <- 1 to 5) yield actorOf(new Chopstick("Chopstick "+i)).start()
//Create 5 awesome hakkers and assign them their left and right chopstick //Create 5 awesome hakkers and assign them their left and right chopstick
val hakkers = for { val hakkers = for {
(name,i) <- List("Ghosh","Bonér","Klang","Krasser","Manie").zipWithIndex (name,i) <- List("Ghosh","Bonér","Klang","Krasser","Manie").zipWithIndex
} yield actorOf(new Hakker(name,chopsticks(i),chopsticks((i+1) % 5))).start } yield actorOf(new Hakker(name,chopsticks(i),chopsticks((i+1) % 5))).start()
//Signal all hakkers that they should start thinking, and watch the show //Signal all hakkers that they should start thinking, and watch the show
hakkers.foreach(_ ! Think) hakkers.foreach(_ ! Think)

View file

@ -168,11 +168,11 @@ object DiningHakkersOnFsm {
def run = { def run = {
// Create 5 chopsticks // Create 5 chopsticks
val chopsticks = for (i <- 1 to 5) yield actorOf(new Chopstick("Chopstick " + i)).start val chopsticks = for (i <- 1 to 5) yield actorOf(new Chopstick("Chopstick " + i)).start()
// Create 5 awesome fsm hakkers and assign them their left and right chopstick // Create 5 awesome fsm hakkers and assign them their left and right chopstick
val hakkers = for{ val hakkers = for{
(name, i) <- List("Ghosh", "Bonér", "Klang", "Krasser", "Manie").zipWithIndex (name, i) <- List("Ghosh", "Bonér", "Klang", "Krasser", "Manie").zipWithIndex
} yield actorOf(new FSMHakker(name, chopsticks(i), chopsticks((i + 1) % 5))).start } yield actorOf(new FSMHakker(name, chopsticks(i), chopsticks((i + 1) % 5))).start()
hakkers.foreach(_ ! Think) hakkers.foreach(_ ! Think)
} }

View file

@ -26,7 +26,7 @@ object ClientManagedRemoteActorServer {
object ClientManagedRemoteActorClient { object ClientManagedRemoteActorClient {
def run = { def run = {
val actor = remote.actorOf[RemoteHelloWorldActor]("localhost",2552).start val actor = remote.actorOf[RemoteHelloWorldActor]("localhost",2552).start()
val result = actor !! "Hello" val result = actor !! "Hello"
} }

View file

@ -94,7 +94,7 @@ object Agent {
*/ */
class Agent[T](initialValue: T) { class Agent[T](initialValue: T) {
private[akka] val ref = Ref(initialValue) private[akka] val ref = Ref(initialValue)
private[akka] val updater = Actor.actorOf(new AgentUpdater(this)).start private[akka] val updater = Actor.actorOf(new AgentUpdater(this)).start()
/** /**
* Read the internal state of the agent. * Read the internal state of the agent.
@ -135,7 +135,7 @@ class Agent[T](initialValue: T) {
*/ */
def sendOff(f: T => T): Unit = send((value: T) => { def sendOff(f: T => T): Unit = send((value: T) => {
suspend suspend
val threadBased = Actor.actorOf(new ThreadBasedAgentUpdater(this)).start val threadBased = Actor.actorOf(new ThreadBasedAgentUpdater(this)).start()
threadBased ! Update(f) threadBased ! Update(f)
value value
}) })

View file

@ -51,9 +51,9 @@ class CoordinatedIncrementSpec extends WordSpec with MustMatchers {
val timeout = 5 seconds val timeout = 5 seconds
def createActors = { def createActors = {
def createCounter(i: Int) = Actor.actorOf(new Counter("counter" + i)).start def createCounter(i: Int) = Actor.actorOf(new Counter("counter" + i)).start()
val counters = (1 to numCounters) map createCounter val counters = (1 to numCounters) map createCounter
val failer = Actor.actorOf(new Failer).start val failer = Actor.actorOf(new Failer).start()
(counters, failer) (counters, failer)
} }

View file

@ -97,9 +97,9 @@ class FickleFriendsSpec extends WordSpec with MustMatchers {
val numCounters = 2 val numCounters = 2
def createActors = { def createActors = {
def createCounter(i: Int) = Actor.actorOf(new FickleCounter("counter" + i)).start def createCounter(i: Int) = Actor.actorOf(new FickleCounter("counter" + i)).start()
val counters = (1 to numCounters) map createCounter val counters = (1 to numCounters) map createCounter
val coordinator = Actor.actorOf(new Coordinator("coordinator")).start val coordinator = Actor.actorOf(new Coordinator("coordinator")).start()
(counters, coordinator) (counters, coordinator)
} }

View file

@ -79,9 +79,9 @@ class TransactorSpec extends WordSpec with MustMatchers {
val timeout = 5 seconds val timeout = 5 seconds
def createTransactors = { def createTransactors = {
def createCounter(i: Int) = Actor.actorOf(new Counter("counter" + i)).start def createCounter(i: Int) = Actor.actorOf(new Counter("counter" + i)).start()
val counters = (1 to numCounters) map createCounter val counters = (1 to numCounters) map createCounter
val failer = Actor.actorOf(new Failer).start val failer = Actor.actorOf(new Failer).start()
(counters, failer) (counters, failer)
} }
@ -113,7 +113,7 @@ class TransactorSpec extends WordSpec with MustMatchers {
"Transactor" should { "Transactor" should {
"be usable without overriding normally" in { "be usable without overriding normally" in {
val transactor = Actor.actorOf(new Setter).start val transactor = Actor.actorOf(new Setter).start()
val ref = Ref(0) val ref = Ref(0)
val latch = new CountDownLatch(1) val latch = new CountDownLatch(1)
transactor ! Set(ref, 5, latch) transactor ! Set(ref, 5, latch)

View file

@ -46,7 +46,7 @@ class TestActor(queue : BlockingDeque[AnyRef]) extends Actor with FSM[Int, TestA
* *
* <pre> * <pre>
* class Test extends TestKit { * class Test extends TestKit {
* val test = actorOf[SomeActor].start * val test = actorOf[SomeActor].start()
* *
* within (1 second) { * within (1 second) {
* test ! SomeWork * test ! SomeWork
@ -77,7 +77,7 @@ trait TestKit {
* ActorRef of the test actor. Access is provided to enable e.g. * ActorRef of the test actor. Access is provided to enable e.g.
* registration as message target. * registration as message target.
*/ */
protected val testActor = actorOf(new TestActor(queue)).start protected val testActor = actorOf(new TestActor(queue)).start()
/** /**
* Implicit sender reference so that replies are possible for messages sent * Implicit sender reference so that replies are possible for messages sent

View file

@ -78,10 +78,10 @@ object Pi extends App {
var nrOfResults: Int = _ var nrOfResults: Int = _
// create the workers // create the workers
val workers = Vector.fill(nrOfWorkers)(actorOf[Worker].start) val workers = Vector.fill(nrOfWorkers)(actorOf[Worker].start())
// wrap them with a load-balancing router // wrap them with a load-balancing router
val router = Routing.loadBalancerActor(CyclicIterator(workers)).start val router = Routing.loadBalancerActor(CyclicIterator(workers)).start()
// phase 1, can accept a Calculate message // phase 1, can accept a Calculate message
def scatter: Receive = { def scatter: Receive = {
@ -124,7 +124,7 @@ object Pi extends App {
// ================== // ==================
def calculate(nrOfWorkers: Int, nrOfElements: Int, nrOfMessages: Int) { def calculate(nrOfWorkers: Int, nrOfElements: Int, nrOfMessages: Int) {
// create the master // create the master
val master = actorOf(new Master(nrOfWorkers, nrOfElements, nrOfMessages)).start val master = actorOf(new Master(nrOfWorkers, nrOfElements, nrOfMessages)).start()
//start the calculation //start the calculation
val start = now val start = now

View file

@ -158,7 +158,7 @@ abstract class TypedActor extends Actor with Proxyable {
/** /**
* User overridable callback. * User overridable callback.
* <p/> * <p/>
* Is called when an Actor is started by invoking 'actor.start'. * Is called when an Actor is started by invoking 'actor.start()'.
*/ */
override def preStart {} override def preStart {}
@ -638,7 +638,7 @@ object TypedActor {
} }
AspectInitRegistry.register(proxy, AspectInit(intfClass, typedActor, actorRef, remoteAddress, actorRef.timeout)) AspectInitRegistry.register(proxy, AspectInit(intfClass, typedActor, actorRef, remoteAddress, actorRef.timeout))
actorRef.start actorRef.start()
proxy.asInstanceOf[T] proxy.asInstanceOf[T]
} }
@ -726,7 +726,7 @@ object TypedActor {
actorRef.timeout = timeout actorRef.timeout = timeout
if (remoteAddress.isDefined) actorRef.makeRemote(remoteAddress.get) if (remoteAddress.isDefined) actorRef.makeRemote(remoteAddress.get)
AspectInitRegistry.register(proxy, AspectInit(targetClass, proxy, actorRef, remoteAddress, timeout)) AspectInitRegistry.register(proxy, AspectInit(targetClass, proxy, actorRef, remoteAddress, timeout))
actorRef.start actorRef.start()
proxy.asInstanceOf[T] proxy.asInstanceOf[T]
} }
*/ */

View file

@ -125,7 +125,7 @@ private[akka] class TypedActorGuiceConfigurator extends TypedActorConfiguratorBa
proxy, proxy,
AspectInit(interfaceClass, typedActor, actorRef, remoteAddress, timeout)) AspectInit(interfaceClass, typedActor, actorRef, remoteAddress, timeout))
typedActor.initialize(proxy) typedActor.initialize(proxy)
actorRef.start actorRef.start()
supervised ::= Supervise(actorRef, component.lifeCycle) supervised ::= Supervise(actorRef, component.lifeCycle)

View file

@ -120,7 +120,7 @@ class TypedActorLifecycleSpec extends Spec with ShouldMatchers with BeforeAndAft
second.fail second.fail
fail("shouldn't get here") fail("shouldn't get here")
} catch { } catch {
case r: ActorInitializationException if r.getMessage == "Actor has not been started, you need to invoke 'actor.start' before using it" => //expected case r: ActorInitializationException if r.getMessage == "Actor has not been started, you need to invoke 'actor.start()' before using it" => //expected
} }
} finally { } finally {
conf.stop conf.stop

View file

@ -131,7 +131,7 @@ class TypedActorSpec extends
assert(typedActors.contains(pojo)) assert(typedActors.contains(pojo))
// creating untyped actor with same custom id // creating untyped actor with same custom id
val actorRef = Actor.actorOf[MyActor].start val actorRef = Actor.actorOf[MyActor].start()
val typedActors2 = Actor.registry.typedActorsFor("my-custom-id") val typedActors2 = Actor.registry.typedActorsFor("my-custom-id")
assert(typedActors2.length === 1) assert(typedActors2.length === 1)
assert(typedActors2.contains(pojo)) assert(typedActors2.contains(pojo))
@ -166,7 +166,7 @@ class TypedActorSpec extends
} }
it("should support foreach for typed actors") { it("should support foreach for typed actors") {
val actorRef = Actor.actorOf[MyActor].start val actorRef = Actor.actorOf[MyActor].start()
assert(Actor.registry.actors.size === 3) assert(Actor.registry.actors.size === 3)
assert(Actor.registry.typedActors.size === 2) assert(Actor.registry.typedActors.size === 2)
Actor.registry.foreachTypedActor(TypedActor.stop(_)) Actor.registry.foreachTypedActor(TypedActor.stop(_))
@ -175,7 +175,7 @@ class TypedActorSpec extends
} }
it("should shutdown all typed and untyped actors") { it("should shutdown all typed and untyped actors") {
val actorRef = Actor.actorOf[MyActor].start val actorRef = Actor.actorOf[MyActor].start()
assert(Actor.registry.actors.size === 3) assert(Actor.registry.actors.size === 3)
assert(Actor.registry.typedActors.size === 2) assert(Actor.registry.typedActors.size === 2)
Actor.registry.shutdownAll() Actor.registry.shutdownAll()