[erlang-patches] Add supervisor:start_child/3 to limit the number of children
Richard Carlsson
carlsson.richard@REDACTED
Wed Apr 3 14:23:31 CEST 2013
On 2013-04-03 14:16, Vance Shipley wrote:
> git fetch git://github.com/vances/otp.git supervisor_child_limit
>
> https://github.com/vances/otp/commit/04f94f86e5495f29b61654d7f744ae3eeaca9297
>
> With the addition of a Limit argument in start_child/3 the supervisor
> will either start a child or return {error,child_limit}.
>
> A supervisor behaviour process may have dynamically added children
> started by other processes. The count of the number of children
> could be retrieved from the process with count_children/1 before
> starting another with start_child/2 if a maximum number of children
> is to be maintained. This introduces an overhead of a round trip
> message and the possibility of a race condition.
>
> This is quite useful where a fixed size pool of processes might
> otherwise be used and is suitable for cases where child workers are
> started with high frequency.
I think that if you're going to add start_child/3, then the third
argument should be a list of options, rather than some specific thing,
making it easy to add more options in the future without having to have
start_child/4 etc.
/Richard
More information about the erlang-patches
mailing list