From d23d4262e24e9c19772a71442bfa4badaa6f8d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attilio=20Don=C3=A0?= Date: Fri, 21 Jun 2024 08:27:22 +0200 Subject: [PATCH] Fix docs --- docs/src/supervisor.md | 16 +++++++++++----- src/Visor.jl | 1 - 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/src/supervisor.md b/docs/src/supervisor.md index 7265ac4..c29787e 100755 --- a/docs/src/supervisor.md +++ b/docs/src/supervisor.md @@ -31,7 +31,8 @@ supervisor(name::String, specs=Spec[]; intensity=1, period=5, strategy=:one_for_one, - restart=:transient) + restart=:transient, + wait=true) ``` It is possible to control the number of restarts of supervised tasks by the two options @@ -66,21 +67,26 @@ function main(task) end end -sv = supervisor("mysupervisor", [interruptable(tsk1), interruptable(tsk2)]); -forever([interruptable(main), sv]); +sv = supervisor("mysupervisor", [process(tsk1), process(tsk2)]); +supervise([process(main), sv]); ``` The `strategy` option defines the restart policy and it is one of: + * `:one_for_one` * `:one_for_all` * `:rest_for_one` * `:one_terminate_all` -The design of the restart strategies `:one_for_one`, `:one_for_all` and `:rest_for_one` follows Erlang behavoir, see [Erlang documentation](https://www.erlang.org/doc/design_principles/sup_princ.html#restart-strategy) for a comprehensive explanation. +The design of the restart strategies `:one_for_one`, `:one_for_all` and `:rest_for_one` follows Erlang behavoir, +see [Erlang documentation](https://www.erlang.org/doc/design_principles/sup_princ.html#restart-strategy) for a comprehensive explanation. The strategy `:one_terminate_all` terminate all supervised processes as soon as the first one terminate, either normally or by an exception. Finally there can be two types of life span for supervisor: `:permanent` and `:transient`. The `:transient` supervisor terminates when there are left no children to supervise, whereas the `:permanent` -supervisor may outlives its supervised children. \ No newline at end of file +supervisor may outlives its supervised children. + +The `wait` option controls if `supervise` blocks or return control. In the latter case it is responsability of the caller to +wait for supervision termination. diff --git a/src/Visor.jl b/src/Visor.jl index 77bc353..1730b99 100755 --- a/src/Visor.jl +++ b/src/Visor.jl @@ -1333,7 +1333,6 @@ supervise( ) function supervise(wait::Bool=true) - #@async wait_signal(__ROOT__) start(__ROOT__) wait && return Base.wait(__ROOT__) end