summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cask/util/src/cask/util/BatchActor.scala11
1 files changed, 10 insertions, 1 deletions
diff --git a/cask/util/src/cask/util/BatchActor.scala b/cask/util/src/cask/util/BatchActor.scala
index 26f1c14..fd4861e 100644
--- a/cask/util/src/cask/util/BatchActor.scala
+++ b/cask/util/src/cask/util/BatchActor.scala
@@ -34,4 +34,13 @@ abstract class BatchActor[T]()(implicit ec: ExecutionContext,
}
}
}
-} \ No newline at end of file
+}
+
+abstract class StateMachine[T]()
+ (implicit ec: ExecutionContext,
+ log: Logger) {
+ class State(val run: T => State)
+ protected[this] def initialState: State
+ protected[this] var state: State = initialState
+ def run(items: Seq[T]): Unit = items.foreach{i => state = state.run(i)}
+}