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 {
"reply to bang message using reply" in {
val replyActor = actorOf[ReplyActor].start
val senderActor = actorOf(new SenderActor(replyActor)).start
val replyActor = actorOf[ReplyActor].start()
val senderActor = actorOf(new SenderActor(replyActor)).start()
senderActor ! "Init"
state.finished.await
state.s must be ("Reply")
}
"reply to bang message using implicit sender" in {
val replyActor = actorOf[ReplyActor].start
val senderActor = actorOf(new SenderActor(replyActor)).start
val replyActor = actorOf[ReplyActor].start()
val senderActor = actorOf(new SenderActor(replyActor)).start()
senderActor ! "InitImplicit"
state.finished.await
state.s must be ("ReplyImplicit")
}
"should shutdown crashed temporary actor" in {
val actor = actorOf[CrashingTemporaryActor].start
val actor = actorOf[CrashingTemporaryActor].start()
actor.isRunning must be (true)
actor ! "Die"
state.finished.await

View file

@ -25,11 +25,11 @@ object ActorRefSpec {
def receive = {
case "complexRequest" => {
replyTo = self.channel
val worker = Actor.actorOf[WorkerActor].start
val worker = Actor.actorOf[WorkerActor].start()
worker ! "work"
}
case "complexRequest2" =>
val worker = Actor.actorOf[WorkerActor].start
val worker = Actor.actorOf[WorkerActor].start()
worker ! self.channel
case "workDone" => replyTo ! "complexReply"
case "simpleRequest" => self.reply("simpleReply")
@ -85,16 +85,16 @@ class ActorRefSpec extends WordSpec with MustMatchers {
val a = Actor.actorOf(new Actor {
val nested = new Actor { def receive = { case _ => } }
def receive = { case _ => }
}).start
}).start()
fail("shouldn't get here")
}
}
"support nested actorOfs" in {
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 }
}).start
}).start()
val nested = (a !! "any").get.asInstanceOf[ActorRef]
a must not be null
@ -103,8 +103,8 @@ class ActorRefSpec extends WordSpec with MustMatchers {
}
"support reply via channel" in {
val serverRef = Actor.actorOf[ReplyActor].start
val clientRef = Actor.actorOf(new SenderActor(serverRef)).start
val serverRef = Actor.actorOf[ReplyActor].start()
val clientRef = Actor.actorOf(new SenderActor(serverRef)).start()
clientRef ! "complex"
clientRef ! "simple"
@ -134,7 +134,7 @@ class ActorRefSpec extends WordSpec with MustMatchers {
case null => self reply_? "null"
}
}
).start
).start()
val ffive: Future[String] = ref !!! 5
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 postRestart(reason: Throwable) = latch.countDown
}
).start
).start()
self link ref
protected def receive = { case "sendKill" => ref ! Kill }
}).start
}).start()
boss ! "sendKill"
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 {
var meetings = 0
self.start
self.start()
mall ! Meet(self, colour)
def receive = {
@ -110,7 +110,7 @@ object Chameneos {
def run {
// System.setProperty("akka.config", "akka.conf")
Chameneos.start = System.currentTimeMillis
actorOf(new Mall(1000000, 4)).start
actorOf(new Mall(1000000, 4)).start()
Thread.sleep(10000)
println("Elapsed: " + (end - start))
}

View file

@ -104,12 +104,12 @@ class FSMActorSpec extends WordSpec with MustMatchers {
"unlock the lock" in {
// 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 = {
case Transition(_, _, _) => transitionCallBackLatch.open
case CurrentState(_, Locked) => initialStateLatch.open
}}).start
}}).start()
lock ! SubscribeTransitionCallBack(transitionTester)
initialStateLatch.await
@ -137,7 +137,7 @@ class FSMActorSpec extends WordSpec with MustMatchers {
case "world" => answerLatch.open
case Bye => lock ! "bye"
}
}).start
}).start()
tester ! Hello
answerLatch.await

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -40,7 +40,7 @@ class SupervisorHierarchySpec extends JUnitSuite {
self.faultHandler = OneForOneStrategy(List(classOf[Throwable]), 5, 1000)
protected def receive = { case _ => () }
}).start
}).start()
val manager = actorOf(new CountDownActor(countDown))
boss.startLink(manager)
@ -67,7 +67,7 @@ class SupervisorHierarchySpec extends JUnitSuite {
case MaximumNumberOfRestartsWithinTimeRangeReached(_, _, _, _) =>
countDown.countDown
}
}).start
}).start()
boss.startLink(crasher)
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 _ => println("received unknown message")
}
}).start
}).start()
val actor2 = Actor.actorOf(new Actor {
self.dispatcher = Dispatchers.newThreadBasedDispatcher(self)
@ -33,7 +33,7 @@ class SupervisorMiscSpec extends WordSpec with MustMatchers {
case "kill" => throw new Exception("killed")
case _ => println("received unknown message")
}
}).start
}).start()
val actor3 = Actor.actorOf(new Actor {
self.dispatcher = Dispatchers.newExecutorBasedEventDrivenDispatcher("test").build
@ -43,7 +43,7 @@ class SupervisorMiscSpec extends WordSpec with MustMatchers {
case "kill" => throw new Exception("killed")
case _ => println("received unknown message")
}
}).start
}).start()
val actor4 = Actor.actorOf(new Actor {
self.dispatcher = Dispatchers.newThreadBasedDispatcher(self)
@ -53,7 +53,7 @@ class SupervisorMiscSpec extends WordSpec with MustMatchers {
case "kill" => throw new Exception("killed")
case _ => println("received unknown message")
}
}).start
}).start()
val sup = Supervisor(
SupervisorConfig(

View file

@ -72,7 +72,7 @@ object SupervisorSpec {
// =====================================================
def temporaryActorAllForOne = {
val temporaryActor = actorOf[TemporaryActor].start
val temporaryActor = actorOf[TemporaryActor].start()
val supervisor = Supervisor(
SupervisorConfig(
@ -86,7 +86,7 @@ object SupervisorSpec {
}
def singleActorAllForOne = {
val pingpong = actorOf[PingPongActor].start
val pingpong = actorOf[PingPongActor].start()
val supervisor = Supervisor(
SupervisorConfig(
@ -100,7 +100,7 @@ object SupervisorSpec {
}
def singleActorOneForOne = {
val pingpong = actorOf[PingPongActor].start
val pingpong = actorOf[PingPongActor].start()
val supervisor = Supervisor(
SupervisorConfig(
@ -114,9 +114,9 @@ object SupervisorSpec {
}
def multipleActorsAllForOne = {
val pingpong1 = actorOf[PingPongActor].start
val pingpong2 = actorOf[PingPongActor].start
val pingpong3 = actorOf[PingPongActor].start
val pingpong1 = actorOf[PingPongActor].start()
val pingpong2 = actorOf[PingPongActor].start()
val pingpong3 = actorOf[PingPongActor].start()
val supervisor = Supervisor(
SupervisorConfig(
@ -138,9 +138,9 @@ object SupervisorSpec {
}
def multipleActorsOneForOne = {
val pingpong1 = actorOf[PingPongActor].start
val pingpong2 = actorOf[PingPongActor].start
val pingpong3 = actorOf[PingPongActor].start
val pingpong1 = actorOf[PingPongActor].start()
val pingpong2 = actorOf[PingPongActor].start()
val pingpong3 = actorOf[PingPongActor].start()
val supervisor = Supervisor(
SupervisorConfig(
@ -209,7 +209,7 @@ class SupervisorSpec extends WordSpec with MustMatchers with BeforeAndAfterEach
"A supervisor" must {
"not restart programmatically linked temporary actor" in {
val master = actorOf[Master].start
val master = actorOf[Master].start()
intercept[RuntimeException] {
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 {
log = "INIT"
val lastActor = actorOf(new Chainer("lastActor")).start
val middleActor = actorOf(new Chainer("middleActor", Some(lastActor))).start
val headActor = actorOf(new Chainer("headActor", Some(middleActor))).start
val lastActor = actorOf(new Chainer("lastActor")).start()
val middleActor = actorOf(new Chainer("middleActor", Some(lastActor))).start()
val headActor = actorOf(new Chainer("headActor", Some(middleActor))).start()
middleActor ! Die
sleepFor(500 millis)

View file

@ -19,7 +19,7 @@ class Ticket669Spec extends WordSpec with MustMatchers with BeforeAndAfterAll {
"A supervised actor with lifecycle PERMANENT" should {
"be able to reply on failure during preRestart" in {
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 supervisor = Supervisor(SupervisorConfig(
@ -33,7 +33,7 @@ class Ticket669Spec extends WordSpec with MustMatchers with BeforeAndAfterAll {
"be able to reply on failure during postStop" in {
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 supervisor = Supervisor(SupervisorConfig(

View file

@ -202,7 +202,7 @@ abstract class ActorModelSpec extends JUnitSuite {
implicit val dispatcher = newInterceptedDispatcher
val a = newTestActor
assertDispatcher(dispatcher)(starts = 0, stops = 0)
a.start
a.start()
assertDispatcher(dispatcher)(starts = 1, stops = 0)
a.stop
await(dispatcher.stops.get == 1)(withinMs = dispatcher.timeoutMs * 5)
@ -222,7 +222,7 @@ abstract class ActorModelSpec extends JUnitSuite {
implicit val dispatcher = newInterceptedDispatcher
val a = newTestActor
val start,oneAtATime = new CountDownLatch(1)
a.start
a.start()
a ! CountDown(start)
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
val a = newTestActor
val counter = new CountDownLatch(200)
a.start
a.start()
def start = spawn { for (i <- 1 to 20) { a ! WaitAck(1, counter) } }
for (i <- 1 to 10) { start }
@ -254,13 +254,13 @@ abstract class ActorModelSpec extends JUnitSuite {
def spawn(f : => Unit) = {
val thread = new Thread { override def run { f } }
thread.start
thread.start()
thread
}
@Test def dispatcherShouldProcessMessagesInParallel: Unit = {
implicit val dispatcher = newInterceptedDispatcher
val a, b = newTestActor.start
val a, b = newTestActor.start()
val aStart,aStop,bParallel = new CountDownLatch(1)
a ! Meet(aStart,aStop)
@ -278,7 +278,7 @@ abstract class ActorModelSpec extends JUnitSuite {
@Test def dispatcherShouldSuspendAndResumeAFailingNonSupervisedPermanentActor {
implicit val dispatcher = newInterceptedDispatcher
val a = newTestActor.start
val a = newTestActor.start()
val done = new CountDownLatch(1)
a ! Restart
a ! CountDown(done)
@ -290,7 +290,7 @@ abstract class ActorModelSpec extends JUnitSuite {
@Test def dispatcherShouldNotProcessMessagesForASuspendedActor {
implicit val dispatcher = newInterceptedDispatcher
val a = newTestActor.start
val a = newTestActor.start()
val done = new CountDownLatch(1)
dispatcher.suspend(a)
a ! CountDown(done)
@ -313,7 +313,7 @@ abstract class ActorModelSpec extends JUnitSuite {
def flood(num: Int) {
val cachedMessage = CountDownNStop(new CountDownLatch(num))
(1 to num) foreach {
_ => newTestActor.start ! cachedMessage
_ => newTestActor.start() ! cachedMessage
}
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
@Test def shouldSendOneWay = {
val actor = actorOf[OneWayTestActor].start
val actor = actorOf[OneWayTestActor].start()
val result = actor ! "OneWay"
assert(OneWayTestActor.oneWay.await(1, TimeUnit.SECONDS))
actor.stop
}
@Test def shouldSendReplySync = {
val actor = actorOf[TestActor].start
val actor = actorOf[TestActor].start()
val result = (actor !! ("Hello", 10000)).as[String]
assert("World" === result.get)
actor.stop
}
@Test def shouldSendReplyAsync = {
val actor = actorOf[TestActor].start
val actor = actorOf[TestActor].start()
val result = actor !! "Hello"
assert("World" === result.get.asInstanceOf[String])
actor.stop
}
@Test def shouldSendReceiveException = {
val actor = actorOf[TestActor].start
val actor = actorOf[TestActor].start()
try {
actor !! "Failure"
fail("Should have thrown an exception")
@ -80,7 +80,7 @@ class ExecutorBasedEventDrivenDispatcherActorSpec extends JUnitSuite {
new Actor {
self.dispatcher = throughputDispatcher
def receive = { case "sabotage" => works.set(false) }
}).start
}).start()
val slowOne = actorOf(
new Actor {
@ -89,7 +89,7 @@ class ExecutorBasedEventDrivenDispatcherActorSpec extends JUnitSuite {
case "hogexecutor" => start.await
case "ping" => if (works.get) latch.countDown
}
}).start
}).start()
slowOne ! "hogexecutor"
(1 to 100) foreach { _ => slowOne ! "ping"}
@ -116,7 +116,7 @@ class ExecutorBasedEventDrivenDispatcherActorSpec extends JUnitSuite {
new Actor {
self.dispatcher = throughputDispatcher
def receive = { case "ping" => if(works.get) latch.countDown; self.stop }
}).start
}).start()
val slowOne = actorOf(
new Actor {
@ -125,7 +125,7 @@ class ExecutorBasedEventDrivenDispatcherActorSpec extends JUnitSuite {
case "hogexecutor" => ready.countDown; start.await
case "ping" => works.set(false); self.stop
}
}).start
}).start()
slowOne ! "hogexecutor"
slowOne ! "ping"

View file

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

View file

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

View file

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

View file

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

View file

@ -36,7 +36,7 @@ class PriorityDispatcherSpec extends WordSpec with MustMatchers {
case i: Int => acc = i :: 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

View file

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

View file

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

View file

@ -22,7 +22,7 @@ class SchedulerSpec extends JUnitSuite {
val countDownLatch = new CountDownLatch(3)
val tickActor = actorOf(new Actor {
def receive = { case Tick => countDownLatch.countDown }
}).start
}).start()
// run every 50 millisec
Scheduler.schedule(tickActor, Tick, 0, 50, TimeUnit.MILLISECONDS)
@ -42,7 +42,7 @@ class SchedulerSpec extends JUnitSuite {
val countDownLatch = new CountDownLatch(3)
val tickActor = actorOf(new Actor {
def receive = { case Tick => countDownLatch.countDown }
}).start
}).start()
// run every 50 millisec
Scheduler.scheduleOnce(tickActor, Tick, 50, TimeUnit.MILLISECONDS)
Scheduler.scheduleOnce( () => countDownLatch.countDown, 50, TimeUnit.MILLISECONDS)
@ -61,7 +61,7 @@ class SchedulerSpec extends JUnitSuite {
val ticks = new CountDownLatch(1000)
val actor = actorOf(new Actor {
def receive = { case Ping => ticks.countDown }
}).start
}).start()
val numActors = Actor.registry.actors.length
(1 to 1000).foreach( _ => Scheduler.scheduleOnce(actor,Ping,1,TimeUnit.MILLISECONDS) )
assert(ticks.await(10,TimeUnit.SECONDS))
@ -77,7 +77,7 @@ class SchedulerSpec extends JUnitSuite {
val actor = actorOf(new Actor {
def receive = { case Ping => ticks.countDown }
}).start
}).start()
(1 to 10).foreach { i =>
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 `testMsg2` => self.reply(7)
}
} ).start
} ).start()
val t2 = actorOf( new Actor() {
def receive = {
case `testMsg3` => self.reply(11)
}
}).start
}).start()
val d = dispatcherActor {
case `testMsg1`|`testMsg2` => t1
case `testMsg3` => t2
}.start
}.start()
val result = for {
a <- (d !! (testMsg1, 5000)).as[Int]
@ -53,8 +53,8 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
@Test def testLogger = {
val msgs = new java.util.concurrent.ConcurrentSkipListSet[Any]
val latch = new CountDownLatch(2)
val t1 = actorOf(new Actor { def receive = { case _ => } }).start
val l = loggerActor(t1,(x) => { msgs.add(x); latch.countDown }).start
val t1 = actorOf(new Actor { def receive = { case _ => } }).start()
val l = loggerActor(t1,(x) => { msgs.add(x); latch.countDown }).start()
val foo : Any = "foo"
val bar : Any = "bar"
l ! foo
@ -76,7 +76,7 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
t1ProcessedCount.incrementAndGet
latch.countDown
}
}).start
}).start()
val t2ProcessedCount = new AtomicInteger(0)
val t2 = actorOf(new Actor {
@ -84,7 +84,7 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
case x => t2ProcessedCount.incrementAndGet
latch.countDown
}
}).start
}).start()
val d = loadBalancerActor(new SmallestMailboxFirstIterator(t1 :: t2 :: Nil))
for (i <- 1 to 500) d ! i
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")
}
})
i.start
i.start()
def newListener = actorOf(new Actor {
def receive = {
@ -111,7 +111,7 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
latch.countDown
case "foo" => foreachListener.countDown
}
}).start
}).start()
val a1 = newListener
val a2 = newListener
@ -142,28 +142,28 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
case `testMsg1` => self.reply(3)
case `testMsg2` => self.reply(7)
}
} ).start
} ).start()
val t2 = actorOf( new Actor() {
def receive = {
case `testMsg1` => self.reply(3)
case `testMsg2` => self.reply(7)
}
} ).start
} ).start()
val t3 = actorOf( new Actor() {
def receive = {
case `testMsg1` => self.reply(3)
case `testMsg2` => self.reply(7)
}
} ).start
} ).start()
val t4 = actorOf( new Actor() {
def receive = {
case `testMsg1` => self.reply(3)
case `testMsg2` => self.reply(7)
}
} ).start
} ).start()
val d1 = loadBalancerActor(new SmallestMailboxFirstIterator(t1 :: t2 :: 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 = {
case "success" => successes.countDown
}
}).start)
}).start())
val pool = actorOf(new TestPool).start
val pool = actorOf(new TestPool).start()
pool ! "a"
pool ! "b"
@ -253,7 +253,7 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
}
}
})
}).start
}).start()
try {
(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
//
val pool = actorOf(new TestPool).start
val pool = actorOf(new TestPool).start()
pool ! 1
(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
}
val pool = actorOf(new TestPool).start
val pool = actorOf(new TestPool).start()
var loops = 0
def loop(t:Int) = {
@ -433,7 +433,7 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
def receive = _route
}
val pool1 = actorOf(new TestPool1).start
val pool1 = actorOf(new TestPool1).start()
pool1 ! "a"
pool1 ! "b"
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)
delegates clear
val pool2 = actorOf(new TestPool2).start
val pool2 = actorOf(new TestPool2).start()
pool2 ! "a"
pool2 ! "b"
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
//
val pool = actorOf(new TestPool).start
val pool = actorOf(new TestPool).start()
for (m <- 0 to 10) pool ! 250
Thread.sleep(5)
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) {
val cachedMessage = CountDownNStop(new CountDownLatch(num))
val keeper = newTestActor.start
val keeper = newTestActor.start()
(1 to num) foreach {
_ => newTestActor.start ! cachedMessage
_ => newTestActor.start() ! cachedMessage
}
keeper.stop
assertCountDown(cachedMessage.latch,10000, "Should process " + num + " countdowns")

View file

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

View file

@ -132,13 +132,13 @@ object Actor extends ListenerManagement {
* <pre>
* import Actor._
* val actor = actorOf[MyActor]
* actor.start
* actor.start()
* actor ! message
* actor.stop
* </pre>
* You can create and start the actor in one statement like this:
* <pre>
* val actor = actorOf[MyActor].start
* val actor = actorOf[MyActor].start()
* </pre>
*/
def actorOf[T <: Actor : Manifest]: ActorRef = actorOf(manifest[T].erasure.asInstanceOf[Class[_ <: Actor]])
@ -148,13 +148,13 @@ object Actor extends ListenerManagement {
* <pre>
* import Actor._
* val actor = actorOf(classOf[MyActor])
* actor.start
* actor.start()
* actor ! message
* actor.stop
* </pre>
* You can create and start the actor in one statement like this:
* <pre>
* val actor = actorOf(classOf[MyActor]).start
* val actor = actorOf(classOf[MyActor]).start()
* </pre>
*/
def actorOf(clazz: Class[_ <: Actor]): ActorRef = new LocalActorRef(() => {
@ -176,13 +176,13 @@ object Actor extends ListenerManagement {
* <pre>
* import Actor._
* val actor = actorOf(new MyActor)
* actor.start
* actor.start()
* actor ! message
* actor.stop
* </pre>
* You can create and start the actor in one statement like this:
* <pre>
* val actor = actorOf(new MyActor).start
* val actor = actorOf(new MyActor).start()
* </pre>
*/
def actorOf(factory: => Actor): ActorRef = new LocalActorRef(() => factory, None)
@ -219,7 +219,7 @@ object Actor extends ListenerManagement {
def receive = {
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>
@ -366,7 +366,7 @@ trait Actor {
/**
* User overridable callback.
* <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 {}

View file

@ -60,14 +60,14 @@ abstract class Channel[T] {
* import Actor._
*
* val actor = actorOf[MyActor]
* actor.start
* actor.start()
* actor ! message
* actor.stop
* </pre>
*
* You can also create and start actors like this:
* <pre>
* val actor = actorOf[MyActor].start
* val actor = actorOf[MyActor].start()
* </pre>
*
* 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._
*
* val actor = actorOf(new MyActor(...))
* actor.start
* actor.start()
* actor ! message
* actor.stop
* </pre>
@ -761,7 +761,7 @@ class LocalActorRef private[akka] (
*/
def startLink(actorRef: ActorRef): Unit = guard.withGuard {
link(actorRef)
actorRef.start
actorRef.start()
}
/**
@ -770,7 +770,7 @@ class LocalActorRef private[akka] (
* To be invoked from within the actor itself.
*/
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.
@ -781,7 +781,7 @@ class LocalActorRef private[akka] (
ensureRemotingEnabled
val ref = Actor.remote.actorOf(clazz, hostname, port)
ref.timeout = timeout
ref.start
ref.start()
}
/**
@ -792,7 +792,7 @@ class LocalActorRef private[akka] (
def spawnLink(clazz: Class[_ <: Actor]): ActorRef = {
val actor = spawn(clazz)
link(actor)
actor.start
actor.start()
actor
}
@ -806,7 +806,7 @@ class LocalActorRef private[akka] (
val actor = Actor.remote.actorOf(clazz, hostname, port)
actor.timeout = timeout
link(actor)
actor.start
actor.start()
actor
}
@ -1296,7 +1296,7 @@ trait ScalaActorRef extends ActorRefShared { ref: ActorRef =>
def !(message: Any)(implicit sender: Option[ActorRef] = None): Unit = {
if (isRunning) postMessageToMailbox(message, sender)
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
} 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] = {
if (isRunning) postMessageToMailboxAndCreateFutureResultWithTimeout[T](message, timeout, sender, None)
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)
else
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 _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
@ -131,7 +131,7 @@ sealed class Supervisor(handler: FaultHandlingStrategy) {
servers.map(server =>
server match {
case Supervise(actorRef, lifeCycle, registerAsRemoteService) =>
actorRef.start
actorRef.start()
val className = actorRef.actor.getClass.getName
val currentActors = {
val list = _childActors.get(className)

View file

@ -86,7 +86,7 @@ abstract class UntypedActor extends Actor {
/**
* User overridable callback.
* <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 {}

View file

@ -40,14 +40,14 @@ object DataFlow {
* Executes the supplied function in another thread.
*/
def thread[A <: AnyRef, R <: AnyRef](body: A => R) =
actorOf(new ReactiveEventBasedThread(body)).start
actorOf(new ReactiveEventBasedThread(body)).start()
/**
* JavaAPI.
* Executes the supplied Function in another thread.
*/
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)
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.
@ -143,7 +143,7 @@ object DataFlow {
*/
def apply(): T = {
value.get getOrElse {
val out = actorOf(new Out(this)).start
val out = actorOf(new Out(this)).start()
val result = try {
blockedReaders offer out

View file

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

View file

@ -137,7 +137,7 @@ case class CannotInstantiateRemoteExceptionDueToRemoteProtocolParsingErrorExcept
abstract class RemoteSupport extends ListenerManagement with RemoteServerModule with RemoteClientModule {
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
addListener(handler)
handler
@ -157,13 +157,13 @@ abstract class RemoteSupport extends ListenerManagement with RemoteServerModule
* <pre>
* import Actor._
* val actor = actorOf(classOf[MyActor],"www.akka.io", 2552)
* actor.start
* actor.start()
* actor ! message
* actor.stop
* </pre>
* You can create and start the actor in one statement like this:
* <pre>
* val actor = actorOf(classOf[MyActor],"www.akka.io", 2552).start
* val actor = actorOf(classOf[MyActor],"www.akka.io", 2552).start()
* </pre>
*/
@deprecated("Will be removed after 1.1")
@ -176,13 +176,13 @@ abstract class RemoteSupport extends ListenerManagement with RemoteServerModule
* <pre>
* import Actor._
* val actor = actorOf(classOf[MyActor],"www.akka.io",2552)
* actor.start
* actor.start()
* actor ! message
* actor.stop
* </pre>
* You can create and start the actor in one statement like this:
* <pre>
* val actor = actorOf(classOf[MyActor],"www.akka.io",2552).start
* val actor = actorOf(classOf[MyActor],"www.akka.io",2552).start()
* </pre>
*/
@deprecated("Will be removed after 1.1")
@ -204,13 +204,13 @@ abstract class RemoteSupport extends ListenerManagement with RemoteServerModule
* <pre>
* import Actor._
* val actor = actorOf[MyActor]("www.akka.io",2552)
* actor.start
* actor.start()
* actor ! message
* actor.stop
* </pre>
* You can create and start the actor in one statement like this:
* <pre>
* val actor = actorOf[MyActor]("www.akka.io",2552).start
* val actor = actorOf[MyActor]("www.akka.io",2552).start()
* </pre>
*/
@deprecated("Will be removed after 1.1")

View file

@ -37,7 +37,7 @@ object Routing {
def loadBalancerActor(actors: => InfiniteIterator[ActorRef]): ActorRef =
actorOf(new Actor with LoadBalancer {
val seq = actors
}).start
}).start()
/**
* Creates a Dispatcher given a routing and a message-transforming function.
@ -46,14 +46,14 @@ object Routing {
actorOf(new Actor with Dispatcher {
override def transform(msg: Any) = msgTransformer(msg)
def routes = routing
}).start
}).start()
/**
* Creates a Dispatcher given a routing.
*/
def dispatcherActor(routing: PF[Any, ActorRef]): ActorRef = actorOf(new Actor with Dispatcher {
def routes = routing
}).start
}).start()
/**
* 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.
*/
def addListener(listener: ActorRef) {
if (manageLifeCycleOfListeners) listener.start
if (manageLifeCycleOfListeners) listener.start()
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.Actor._
val listener = actorOf[RegistryListener].start
val listener = actorOf[RegistryListener].start()
registry.addListener(listener)

View file

@ -41,7 +41,7 @@ Creating Actors
.. code-block:: scala
val myActor = Actor.actorOf[MyActor]
myActor.start
myActor.start()
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
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.
@ -70,7 +70,7 @@ Here is an example:
.. 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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -370,13 +370,13 @@ Actors are started by invoking the ``start`` method.
.. code-block:: scala
val actor = actorOf[MyActor]
actor.start
actor.start()
You can create and start the ``Actor`` in a oneliner like this:
.. 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.
@ -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 Ho

View file

@ -336,7 +336,7 @@ Here is an example:
victimActorRef, maxNrOfRetries, withinTimeRange, lastExceptionCausingRestart) =>
... // handle the error situation
}
}).start
}).start()
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]) {
val lock = Actor.actorOf(new Lock("1234")).start
val lock = Actor.actorOf(new Lock("1234")).start()
lock ! '1'
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 provide(uri: String): ActorRef = {
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
//
lazy val same = actorOf[BoringActor].start
lazy val same = actorOf[BoringActor].start()
}
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 form parameter named "Data"
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 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
@ -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
//
lazy val complete = actorOf[ActionCompleteActor].start
lazy val complete = actorOf[ActionCompleteActor].start()
}
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._
remote.start
remote.start()
// Specify the classloader to use to load the remote class (actor)
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 _ => //ignore other
}
}).start
}).start()
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 RemoteServerWriteFailed(request, casue, server, clientAddress) => ... // act upon server write failure
}
}).start
}).start()
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
//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 ponger = actorOf(new Actor { def receive = { case x => println("Ponger: " + 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()
//A dispatcher that dispatches Ping messages to the pinger
//and Pong messages to the ponger
@ -48,8 +48,8 @@ Or by mixing in akka.patterns.Dispatcher:
class MyDispatcher extends Actor with Dispatcher {
//Our pinger and ponger actors
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 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()
//When we get a ping, we dispatch to the pinger
//When we get a pong, we dispatch to the ponger
def routes = {
@ -59,7 +59,7 @@ Or by mixing in akka.patterns.Dispatcher:
}
//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 ! Pong //Prints "Ponger: Pong"
@ -85,8 +85,8 @@ Example using the **loadBalancerActor()** factory method:
//Two actors, one named Pinger and one named Ponger
//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 ponger = actorOf(new Actor { def receive = { case x => println("Ponger: " + 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()
//A load balancer that given a sequence of actors dispatches them accordingly
//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
class MyLoadBalancer extends Actor with LoadBalancer {
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 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 seq = new CyclicIterator[ActorRef](List(pinger,ponger))
}
//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 "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 BinaryFormatMyActor._
val actor1 = actorOf[MyActor].start
val actor1 = actorOf[MyActor].start()
(actor1 !! "hello").getOrElse("_") should equal("world 1")
(actor1 !! "hello").getOrElse("_") should equal("world 2")
val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes)
actor2.start
actor2.start()
(actor2 !! "hello").getOrElse("_") should equal("world 3")
}
@ -128,13 +128,13 @@ and use it for serialization:
import akka.serialization.ActorSerialization._
import BinaryFormatMyStatelessActor._
val actor1 = actorOf[MyStatelessActor].start
val actor1 = actorOf[MyStatelessActor].start()
(actor1 !! "hello").getOrElse("_") should equal("world")
(actor1 !! "hello").getOrElse("_") should equal("world")
val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes)
actor2.start
actor2.start()
(actor2 !! "hello").getOrElse("_") should equal("world")
}
@ -182,13 +182,13 @@ and serialize / de-serialize ..
import akka.serialization.ActorSerialization._
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 2")
val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes)
actor2.start
actor2.start()
(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 account2 = Ref(100.0)
val transferer = Actor.actorOf(new Transferer).start
val transferer = Actor.actorOf(new Transferer).start()
transferer ! Transfer(account1, account2, 500.0)
// 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 ref2 = Ref(0)
val brancher = Actor.actorOf(new Brancher).start
val brancher = Actor.actorOf(new Brancher).start()
brancher ! Branch(ref1, ref2, 1)
// 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 {
val echoRef = actorOf(new EchoActor).start
val forwardRef = actorOf(new ForwardingActor(testActor)).start
val filterRef = actorOf(new FilteringActor(testActor)).start
val echoRef = actorOf(new EchoActor).start()
val forwardRef = actorOf(new ForwardingActor(testActor)).start()
val filterRef = actorOf(new FilteringActor(testActor)).start()
val randomHead = Random.nextInt(6)
val randomTail = Random.nextInt(10)
val headList = List().padTo(randomHead, "0")
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 = {
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 counter2 = Actor.actorOf[Counter].start
val counter1 = Actor.actorOf[Counter].start()
val counter2 = Actor.actorOf[Counter].start()
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]
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
@ -260,7 +260,7 @@ The 'shutdownSessions' function simply shuts all the sessions Actors down. That
case Login(username) =>
EventHandler.info(this, "User [%s] has logged in".format(username))
val session = actorOf(new Session(username, storage))
session.start
session.start()
sessions += (username -> session)
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.
* Start service by invoking:
* <pre>
* val chatService = Actor.actorOf[ChatService].start
* val chatService = Actor.actorOf[ChatService].start()
* </pre>
*/
class ChatService extends
@ -505,7 +505,7 @@ Run a sample chat session
import sample.chat._
import akka.actor.Actor._
val chatService = actorOf[ChatService].start
val chatService = actorOf[ChatService].start()
3. In the second REPL you get execute:

View file

@ -34,7 +34,7 @@ class BasicAuthenticatorSpec extends junit.framework.TestCase
import BasicAuthenticatorSpec._
val authenticator = actorOf[BasicAuthenticator]
authenticator.start
authenticator.start()
@Test def testChallenge = {
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
}, "Akka Remote Service")
def startRemoteService = remoteServerThread.start
def startRemoteService = remoteServerThread.start()
abstract override def onLoad = {
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]) {
if (_isRunning.isOn) {
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()
actorRef.uuid = parseUuid(uuid) //FIXME is this sensible?
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
}
@ -1148,7 +1148,7 @@ class RemoteServerHandler(
actorRef.id = id
actorRef.timeout = timeout
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 {
case e: Throwable =>
EventHandler.error(e, this, e.getMessage)

View file

@ -58,7 +58,7 @@ class AkkaRemoteTest extends
/* 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 =>

View file

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

View file

@ -14,7 +14,7 @@ class OptimizedLocalScopedSpec extends AkkaRemoteTest {
"An enabled optimized local scoped remote" should {
"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.actorFor("foo", host, port) must be (fooActor)

View file

@ -109,7 +109,7 @@ class RemoteErrorHandlingNetworkTest extends AkkaRemoteTest with NetworkFailureT
val actor = remote.actorFor(
"akka.actor.remote.ServerInitiatedRemoteActorSpec$RemoteActorSpecActorBidirectional", timeout, host, port)
val latch = new CountDownLatch(1)
val sender = actorOf( new RemoteActorSpecActorAsyncSender(latch) ).start
val sender = actorOf( new RemoteActorSpecActorAsyncSender(latch) ).start()
sender ! Send(actor)
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
// 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(
SupervisorConfig(
@ -240,7 +240,7 @@ class RemoteSupervisorSpec extends AkkaRemoteTest {
}
def getSingleActorOneForOneSupervisor: Supervisor = {
pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start
pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start()
val factory = SupervisorFactory(
SupervisorConfig(
@ -253,9 +253,9 @@ class RemoteSupervisorSpec extends AkkaRemoteTest {
}
def getMultipleActorsAllForOneConf: Supervisor = {
pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start
pingpong2 = remote.actorOf[RemotePingPong2Actor](host,port).start
pingpong3 = remote.actorOf[RemotePingPong3Actor](host,port).start
pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start()
pingpong2 = remote.actorOf[RemotePingPong2Actor](host,port).start()
pingpong3 = remote.actorOf[RemotePingPong3Actor](host,port).start()
val factory = SupervisorFactory(
SupervisorConfig(
@ -276,9 +276,9 @@ class RemoteSupervisorSpec extends AkkaRemoteTest {
}
def getMultipleActorsOneForOneConf: Supervisor = {
pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start
pingpong2 = remote.actorOf[RemotePingPong2Actor](host,port).start
pingpong3 = remote.actorOf[RemotePingPong3Actor](host,port).start
pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start()
pingpong2 = remote.actorOf[RemotePingPong2Actor](host,port).start()
pingpong3 = remote.actorOf[RemotePingPong3Actor](host,port).start()
val factory = SupervisorFactory(
SupervisorConfig(
@ -299,9 +299,9 @@ class RemoteSupervisorSpec extends AkkaRemoteTest {
}
def getNestedSupervisorsAllForOneConf: Supervisor = {
pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start
pingpong2 = remote.actorOf[RemotePingPong2Actor](host,port).start
pingpong3 = remote.actorOf[RemotePingPong3Actor](host,port).start
pingpong1 = remote.actorOf[RemotePingPong1Actor](host,port).start()
pingpong2 = remote.actorOf[RemotePingPong2Actor](host,port).start()
pingpong3 = remote.actorOf[RemotePingPong3Actor](host,port).start()
val factory = SupervisorFactory(
SupervisorConfig(

View file

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

View file

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

View file

@ -13,7 +13,7 @@ class UnOptimizedLocalScopedSpec extends AkkaRemoteTest {
"An enabled optimized local scoped remote" should {
"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.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") {
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 2")
val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes)
actor2.start
actor2.start()
(actor2 !! "hello").getOrElse("_") should equal("world 3")
}
it("should be able to serialize and de-serialize a stateful actor with compound state") {
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 2 2")
val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes)
actor2.start
actor2.start()
(actor2 !! "hello").getOrElse("_") should equal("world 3 3")
}
it("should be able to serialize and de-serialize a stateless actor") {
import BinaryFormatMyStatelessActor._
val actor1 = actorOf[MyStatelessActor].start
val actor1 = actorOf[MyStatelessActor].start()
(actor1 !! "hello").getOrElse("_") should equal("world")
(actor1 !! "hello").getOrElse("_") should equal("world")
val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes)
actor2.start
actor2.start()
(actor2 !! "hello").getOrElse("_") should equal("world")
}
it("should be able to serialize and de-serialize a stateful actor with a given serializer") {
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 2")
val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes)
actor2.start
actor2.start()
(actor2 !! "hello").getOrElse("_") should equal("world 3")
actor2.receiveTimeout should equal (Some(1000))
@ -122,7 +122,7 @@ class SerializableTypeClassActorSpec extends
it("should be able to serialize and deserialize a MyStatelessActorWithMessagesInMailbox") {
import BinaryFormatMyStatelessActorWithMessagesInMailbox._
val actor1 = actorOf[MyStatelessActorWithMessagesInMailbox].start
val actor1 = actorOf[MyStatelessActorWithMessagesInMailbox].start()
(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'") {
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 2")
actor1 ! "swap"
@ -155,7 +155,7 @@ class SerializableTypeClassActorSpec extends
val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes)
actor2.start
actor2.start()
(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") {
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 2")
actor1 ! HotSwap {
@ -177,7 +177,7 @@ class SerializableTypeClassActorSpec extends
val bytes = toBinary(actor1)
val actor2 = fromBinary(bytes)
actor2.start
actor2.start()
(actor1 !! "hello").getOrElse("_") should equal("swapped")
@ -190,7 +190,7 @@ class SerializableTypeClassActorSpec extends
it("should serialize and de-serialize") {
import BinaryFormatMyActorWithSerializableMessages._
val actor1 = actorOf[MyActorWithSerializableMessages].start
val actor1 = actorOf[MyActorWithSerializableMessages].start()
(actor1 ! MyMessage("hello1", ("akka", 100)))
(actor1 ! MyMessage("hello2", ("akka", 200)))
(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") {
import BinaryFormatMyStatelessActorWithMessagesInMailbox._
val actor1 = actorOf[MyStatelessActorWithMessagesInMailbox].start
val actor1 = actorOf[MyStatelessActorWithMessagesInMailbox].start()
(actor1 ! "hello")
(actor1 ! "hello")
(actor1 ! "hello")
@ -65,7 +65,7 @@ class Ticket435Spec extends
it("should serialize the mailbox optionally") {
import BinaryFormatMyStatelessActorWithMessagesInMailbox._
val actor1 = actorOf[MyStatelessActorWithMessagesInMailbox].start
val actor1 = actorOf[MyStatelessActorWithMessagesInMailbox].start()
(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") {
import BinaryFormatMyStatefulActor._
val actor1 = actorOf[MyStatefulActor].start
val actor1 = actorOf[MyStatefulActor].start()
(actor1 ! "hi")
(actor1 ! "hi")
(actor1 ! "hi")

View file

@ -43,37 +43,37 @@ class UntypedActorSerializationSpec extends
describe("Serializable 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("debasish") should equal("hello debasish 2")
val f = new MyUntypedActorFormat
val bytes = toBinaryJ(actor1, f)
val actor2 = fromBinaryJ(bytes, f)
actor2.start
actor2.start()
actor2.sendRequestReply("hello") should equal("world 3")
}
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 2 2")
val f = new MyUntypedActorWithDualCounterFormat
val bytes = toBinaryJ(actor1, f)
val actor2 = fromBinaryJ(bytes, f)
actor2.start
actor2.start()
actor2.sendRequestReply("hello") should equal("world 3 3")
}
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")
val bytes = toBinaryJ(actor1, MyUntypedStatelessActorFormat)
val actor2 = fromBinaryJ(bytes, MyUntypedStatelessActorFormat)
actor2.start
actor2.start()
actor2.sendRequestReply("hello") should equal("world")
}
}

View file

@ -65,7 +65,7 @@ object World {
val homeOff = Dim / 4
lazy val places = Vector.fill(Dim, Dim)(new Place)
lazy val ants = setup
lazy val evaporator = actorOf[Evaporator].start
lazy val evaporator = actorOf[Evaporator].start()
private val snapshotFactory = TransactionFactory(readonly = true, familyName = "snapshot")
@ -81,7 +81,7 @@ object World {
for (x <- homeRange; y <- homeRange) yield {
place(x, y).makeHome
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:
- scala> import sample.chat._
- 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:
- scala> import sample.chat._
- scala> ClientRunner.run

View file

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

View file

@ -168,11 +168,11 @@ object DiningHakkersOnFsm {
def run = {
// 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
val hakkers = for{
(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)
}

View file

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

View file

@ -94,7 +94,7 @@ object Agent {
*/
class Agent[T](initialValue: T) {
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.
@ -135,7 +135,7 @@ class Agent[T](initialValue: T) {
*/
def sendOff(f: T => T): Unit = send((value: T) => {
suspend
val threadBased = Actor.actorOf(new ThreadBasedAgentUpdater(this)).start
val threadBased = Actor.actorOf(new ThreadBasedAgentUpdater(this)).start()
threadBased ! Update(f)
value
})

View file

@ -51,9 +51,9 @@ class CoordinatedIncrementSpec extends WordSpec with MustMatchers {
val timeout = 5 seconds
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 failer = Actor.actorOf(new Failer).start
val failer = Actor.actorOf(new Failer).start()
(counters, failer)
}

View file

@ -97,9 +97,9 @@ class FickleFriendsSpec extends WordSpec with MustMatchers {
val numCounters = 2
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 coordinator = Actor.actorOf(new Coordinator("coordinator")).start
val coordinator = Actor.actorOf(new Coordinator("coordinator")).start()
(counters, coordinator)
}

View file

@ -79,9 +79,9 @@ class TransactorSpec extends WordSpec with MustMatchers {
val timeout = 5 seconds
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 failer = Actor.actorOf(new Failer).start
val failer = Actor.actorOf(new Failer).start()
(counters, failer)
}
@ -113,7 +113,7 @@ class TransactorSpec extends WordSpec with MustMatchers {
"Transactor" should {
"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 latch = new CountDownLatch(1)
transactor ! Set(ref, 5, latch)

View file

@ -46,7 +46,7 @@ class TestActor(queue : BlockingDeque[AnyRef]) extends Actor with FSM[Int, TestA
*
* <pre>
* class Test extends TestKit {
* val test = actorOf[SomeActor].start
* val test = actorOf[SomeActor].start()
*
* within (1 second) {
* test ! SomeWork
@ -77,7 +77,7 @@ trait TestKit {
* ActorRef of the test actor. Access is provided to enable e.g.
* 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

View file

@ -78,10 +78,10 @@ object Pi extends App {
var nrOfResults: Int = _
// 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
val router = Routing.loadBalancerActor(CyclicIterator(workers)).start
val router = Routing.loadBalancerActor(CyclicIterator(workers)).start()
// phase 1, can accept a Calculate message
def scatter: Receive = {
@ -124,7 +124,7 @@ object Pi extends App {
// ==================
def calculate(nrOfWorkers: Int, nrOfElements: Int, nrOfMessages: Int) {
// create the master
val master = actorOf(new Master(nrOfWorkers, nrOfElements, nrOfMessages)).start
val master = actorOf(new Master(nrOfWorkers, nrOfElements, nrOfMessages)).start()
//start the calculation
val start = now

View file

@ -158,7 +158,7 @@ abstract class TypedActor extends Actor with Proxyable {
/**
* User overridable callback.
* <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 {}
@ -638,7 +638,7 @@ object TypedActor {
}
AspectInitRegistry.register(proxy, AspectInit(intfClass, typedActor, actorRef, remoteAddress, actorRef.timeout))
actorRef.start
actorRef.start()
proxy.asInstanceOf[T]
}
@ -726,7 +726,7 @@ object TypedActor {
actorRef.timeout = timeout
if (remoteAddress.isDefined) actorRef.makeRemote(remoteAddress.get)
AspectInitRegistry.register(proxy, AspectInit(targetClass, proxy, actorRef, remoteAddress, timeout))
actorRef.start
actorRef.start()
proxy.asInstanceOf[T]
}
*/

View file

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

View file

@ -120,7 +120,7 @@ class TypedActorLifecycleSpec extends Spec with ShouldMatchers with BeforeAndAft
second.fail
fail("shouldn't get here")
} 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 {
conf.stop

View file

@ -131,7 +131,7 @@ class TypedActorSpec extends
assert(typedActors.contains(pojo))
// 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")
assert(typedActors2.length === 1)
assert(typedActors2.contains(pojo))
@ -166,7 +166,7 @@ class TypedActorSpec extends
}
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.typedActors.size === 2)
Actor.registry.foreachTypedActor(TypedActor.stop(_))
@ -175,7 +175,7 @@ class TypedActorSpec extends
}
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.typedActors.size === 2)
Actor.registry.shutdownAll()