Mercurial > hg > Members > anatofuz > akka-increment-sample
changeset 3:4ceb0fc4c564
clear up method name and variable names
author | Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 29 Jan 2018 17:03:25 +0900 |
parents | 2a754f9be68f |
children | a0d72969e6b4 |
files | src/main/scala/IncrementSample.scala |
diffstat | 1 files changed, 7 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/scala/IncrementSample.scala Mon Jan 29 16:46:26 2018 +0900 +++ b/src/main/scala/IncrementSample.scala Mon Jan 29 17:03:25 2018 +0900 @@ -2,16 +2,13 @@ import akka.actor.{Actor, ActorLogging, ActorRef, ActorSystem, Props, TypedActor} -import akka.japi.Util -import scala.concurrent.Await object Incrementer { - //def props: Props = Props[Incrementer] def props(printerActor:ActorRef): Props = Props(new Incrementer(printerActor)) final case class SendData(data:Int) - final case class SendActor(actor:ActorRef) + final case class SetActor(actor:ActorRef) } class Incrementer(printerActor: ActorRef) extends Actor { @@ -25,15 +22,13 @@ def receive = { case SendData(data) => if (data < 10 ) { - //val send_data = incrementData(data) val send_data = data + 1 otherActor ! SendData(send_data) printerActor ! Println(send_data.toString) } else { - // インクリメント終了を伝達 printerActor ! Println("fin") } - case SendActor(actor :ActorRef) => + case SetActor(actor :ActorRef) => otherActor = actor } } @@ -62,12 +57,12 @@ val printer: ActorRef = system.actorOf(Printer.props,"printerActor") - val hoge: ActorRef = system.actorOf(Incrementer.props(printer),"HogeActor") + val actorOne: ActorRef = system.actorOf(Incrementer.props(printer),"ActorOne") - val foo: ActorRef = system.actorOf(Incrementer.props(printer),"FooActor") + val actorTwo: ActorRef = system.actorOf(Incrementer.props(printer),"ActorTwo") - foo ! SendActor(hoge) - hoge ! SendActor(foo) + actorOne ! SetActor(actorTwo) + actorTwo ! SetActor(actorOne) - foo ! SendData(1:Int) + actorOne ! SendData(1:Int) }