I tried to implement this like the following:
class RecomputationActor(codeBlock: =>Unit) extends Actor with
FSM[ActorState,Boolean] {
startWith(Idle,false)
when(Idle){
case Event(event,_) =>goto(Processing) using(false)
}
when(Processing){
case Event(event,_) => stay using(true)
}
onTransition{
case Idle->Processing => codeBlock; goto(Idle)
case Processing->Idle => if(nextStateData)
goto(Processing) using false
}
initialize
}
However when I test it, nothing happens:
class RecomputationActorTest extends Spec {
val system = ActorSystem("MySystem")
describe("A recomputation actor "){
it("must change state correctly"){
val actor = system.actorOf(Props(new RecomputationActor( {
println("hello")
Thread.sleep(100)
} )
with LoggingFSM[ActorState,Boolean] ))
actor ! "Compute"
actor ! "Compute"
actor ! "Compute"
actor ! "Compute"
}
}
}
Where am I wrong?
2012/5/24 Edmondo Porcu <
edmond...@gmail.com>: