summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/pages/4 - Cask Actors.md9
1 files changed, 8 insertions, 1 deletions
diff --git a/docs/pages/4 - Cask Actors.md b/docs/pages/4 - Cask Actors.md
index d5799f0..5c7cd27 100644
--- a/docs/pages/4 - Cask Actors.md
+++ b/docs/pages/4 - Cask Actors.md
@@ -422,6 +422,11 @@ override def run(msg: Msg): Unit = {
}
```
+Note that if you have multiple actors sending messages to each other, by default
+they run on a thread pool and so the `println` messages above may become
+interleaved and hard to read. To resolve that, you can try
+[Running Actors Single Threaded](#running-actors-single-threaded).
+
### Debugging using Context Logging
Apart from logging individual Actors, you can also insert logging into the
@@ -461,6 +466,8 @@ cask.actor.JvmActorsTest$Writer$2@3bb87fa0 <- SSBhbSBjb3csIEkgYW0gY293
cask.actor.JvmActorsTest$Writer$2@3bb87fa0 <- SGVhciBtZSBtb28sIG1vb29v
```
+### Running Actors Single Threaded
+
We can also replace the default `scala.concurrent.ExecutionContext.global`
executor with a single-threaded executor, if we want our Actor pipeline to
behave 100% deterministically:
@@ -482,4 +489,4 @@ Any asynchronous Actor pipeline should be able to run no a
`newSingleThreadExecutor`. While it would be slower than running on the default
thread pool, it should make execution of your actors much more deterministic -
only one actor will be running at a time - and make it easier to track down
-logical bugs without multithreaded parallelism getting in the way. \ No newline at end of file
+logical bugs without multithreaded parallelism getting in the way.