Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
attdona committed Jun 21, 2024
1 parent bcba7c1 commit d23d426
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 11 additions & 5 deletions docs/src/supervisor.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
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.
1 change: 0 additions & 1 deletion src/Visor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,6 @@ supervise(
)

function supervise(wait::Bool=true)
#@async wait_signal(__ROOT__)
start(__ROOT__)
wait && return Base.wait(__ROOT__)
end
Expand Down

0 comments on commit d23d426

Please sign in to comment.