You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

25 regels
645 B

-module(tpTracerPool).
-behaviour(supervisor).
-export([
start_link/3
, init/1
, tracers/1
]).
start_link(NumTracers, TracerMod, Opts) ->
supervisor:start_link(?MODULE, [NumTracers, TracerMod, Opts]).
init([NumTracers, TracerMod, Opts]) ->
ChildSpecs = [
#{
id => {tracer, Index},
start => {TracerMod, start_link, [Index, Opts]},
restart => temporary
} || Index <- lists:seq(1, NumTracers)
],
SupFlags = #{strategy => one_for_all, intensity => 5, period => 10},
{ok, {SupFlags, ChildSpecs}}.
tracers(PoolPid) ->
[Pid || {_, Pid, _, _} <- supervisor:which_children(PoolPid)].