summaryrefslogtreecommitdiff
path: root/src/Control/Concurrent/Supervisor/Tutorial.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Control/Concurrent/Supervisor/Tutorial.hs')
-rw-r--r--src/Control/Concurrent/Supervisor/Tutorial.hs20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/Control/Concurrent/Supervisor/Tutorial.hs b/src/Control/Concurrent/Supervisor/Tutorial.hs
index 86aa37a..c02b72f 100644
--- a/src/Control/Concurrent/Supervisor/Tutorial.hs
+++ b/src/Control/Concurrent/Supervisor/Tutorial.hs
@@ -93,7 +93,7 @@ module Control.Concurrent.Supervisor.Tutorial
-- > type Supervisor = Supervisor_ Initialised
-- The important difference though, is that the `SupervisorSpec` does not imply the creation
-- of an asynchronous thread, which the latter does. To keep separated the initialisation
--- of the data structure from the logic of supervising, we use GADTs and type synonyms to
+-- of the data structure from the logic of supervising, we use phantom types to
-- force you create a spec first.
-- Creating a spec it just a matter of calling `newSupervisorSpec`.
@@ -114,11 +114,11 @@ module Control.Concurrent.Supervisor.Tutorial
-- >
-- > sup1 `monitor` sup2
-- >
--- > _ <- forkSupervised sup2 OneForOne job3
+-- > _ <- forkSupervised sup2 oneForOne job3
-- >
--- > j1 <- forkSupervised sup1 OneForOne job1
--- > _ <- forkSupervised sup1 OneForOne (job2 j1)
--- > _ <- forkSupervised sup1 OneForOne job4
+-- > j1 <- forkSupervised sup1 oneForOne job1
+-- > _ <- forkSupervised sup1 oneForOne (job2 j1)
+-- > _ <- forkSupervised sup1 oneForOne job4
-- > _ <- forkIO (go (eventStream sup1))
-- > return sup1) shutdownSupervisor (\_ -> threadDelay 10000000000)
-- > where
@@ -136,6 +136,16 @@ module Control.Concurrent.Supervisor.Tutorial
-- (from the same spec, but you can create a separate one as well)
-- and we ask the first supervisor to monitor the second one.
--
+-- `oneForOne` is a smart constructor for our `RestartStrategy`,which creates
+-- under the hood a `OneForOne` strategy which is using the `fibonacciBackoff`
+-- as `RetryPolicy` from the "retry" package. The clear advantage is that
+-- you are not obliged to use it if you don't like this sensible default;
+-- `RetryPolicy` is an monoid, so you can compose retry policies as you wish.
+--
+-- The `RetryPolicy` will also be responsible for determining whether a thread can be
+-- restarted or not; in the latter case you will find a `ChildRestartedLimitReached`
+-- in your event log.
+--
-- If you run this program, hopefully you should see on stdout
-- something like this:
--