summaryrefslogtreecommitdiff
path: root/cask
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2019-11-05 08:49:58 +0800
committerLi Haoyi <haoyi.sg@gmail.com>2019-11-05 08:49:58 +0800
commit35d3af1cd09d36c31744d214f0cadc3dd2ac51b2 (patch)
tree9c5a62ed0896d88f100b3c64e92bbae6335fa80e /cask
parent3c7b7e70beb9013755bcaa0e724190bdfc8c99ea (diff)
downloadcask-35d3af1cd09d36c31744d214f0cadc3dd2ac51b2.tar.gz
cask-35d3af1cd09d36c31744d214f0cadc3dd2ac51b2.tar.bz2
cask-35d3af1cd09d36c31744d214f0cadc3dd2ac51b2.zip
0.3.40.3.4
Diffstat (limited to 'cask')
-rw-r--r--cask/actor/src/Actors.scala8
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