Created
November 3, 2010 18:28
-
-
Save momania/661478 to your computer and use it in GitHub Desktop.
Akka FSM Goto 10 FTW!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GotoFsm extends Actor with FSM[Int, Null] { | |
notifying { | |
case Transition(_, 10) => println("Goto 10 ftw!") | |
} | |
when(0) { | |
case _ => goto(10) until 5000 | |
} | |
when(10) { | |
case _ => stop | |
} | |
startWith(0, null) | |
onTermination { | |
case _ => println("Bye bye :-)") | |
} | |
} | |
case object Go | |
object GotoFsm { | |
def main(args: Array[String]) { | |
val gotoFsm = Actor.actorOf[GotoFsm].start | |
gotoFsm !! Go | |
} | |
} |
() / Unit is a touch more idiomatic Scala than null / Null. Otherwise, I like!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool. Add it to the akka docs.