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 line
645 B

  1. -module(tpTracerPool).
  2. -behaviour(supervisor).
  3. -export([
  4. start_link/3
  5. , init/1
  6. , tracers/1
  7. ]).
  8. start_link(NumTracers, TracerMod, Opts) ->
  9. supervisor:start_link(?MODULE, [NumTracers, TracerMod, Opts]).
  10. init([NumTracers, TracerMod, Opts]) ->
  11. ChildSpecs = [
  12. #{
  13. id => {tracer, Index},
  14. start => {TracerMod, start_link, [Index, Opts]},
  15. restart => temporary
  16. } || Index <- lists:seq(1, NumTracers)
  17. ],
  18. SupFlags = #{strategy => one_for_all, intensity => 5, period => 10},
  19. {ok, {SupFlags, ChildSpecs}}.
  20. tracers(PoolPid) ->
  21. [Pid || {_, Pid, _, _} <- supervisor:which_children(PoolPid)].