diff options
Diffstat (limited to 'cask/actor')
-rw-r--r-- | cask/actor/src/Actors.scala | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/cask/actor/src/Actors.scala b/cask/actor/src/Actors.scala index 69a5289..84975ba 100644 --- a/cask/actor/src/Actors.scala +++ b/cask/actor/src/Actors.scala @@ -69,10 +69,16 @@ abstract class SimpleActor[T]()(implicit ac: Context) extends BaseActor[T]{ } abstract class StateMachineActor[T]()(implicit ac: Context) extends SimpleActor[T]() { - class State(val run: T => State) + class State(val run: T => State = null) protected[this] def initialState: State protected[this] var state: State = initialState def run(msg: T): Unit = { + assert(state != null) state = state.run(msg) } +} + +class ProxyActor[T, V](f: T => V, downstream: Actor[V]) + (implicit ac: Context) extends SimpleActor[T]{ + def run(msg: T): Unit = downstream.send(f(msg)) }
\ No newline at end of file |