[erlang-patches] Add supervisor:start_child/3 to limit the number of children
Vance Shipley
vances@REDACTED
Wed Apr 3 14:16:37 CEST 2013
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.
--
-Vance
More information about the erlang-patches
mailing list