diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2019-11-04 07:06:01 +0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2019-11-04 07:06:01 +0800 |
commit | b9716a7da6c3f3587ddd9918fd5048903ec78296 (patch) | |
tree | 6445e6a56b927c596076116fa5d802c7e2a01bd8 /docs | |
parent | 1bca62fe08a1b713a11004b0c2a995dfa7e83bd8 (diff) | |
download | cask-b9716a7da6c3f3587ddd9918fd5048903ec78296.tar.gz cask-b9716a7da6c3f3587ddd9918fd5048903ec78296.tar.bz2 cask-b9716a7da6c3f3587ddd9918fd5048903ec78296.zip |
actor readme
Diffstat (limited to 'docs')
-rw-r--r-- | docs/pages/4 - Cask Actors.md | 9 |
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. |