2 -behaviour(supervisor).
6 -export([start_link/3]).
12 %% Helper macro for declaring children of supervisor
13 -define(CHILD(Type, I, Args), {I, {I, start_link, Args}, permanent, 5000, Type, [I]}).
16 %% ============================================================================
18 %% ============================================================================
20 start_link(X, Y, CellData) ->
21 supervisor:start_link({local, ?MODULE}, ?MODULE, [X, Y, CellData]).
24 %% ============================================================================
26 %% ============================================================================
28 init([X, Y, CellData]) ->
29 CellNames = [Name || {_, Name, _} <- CellData],
30 RestartStrategy = {one_for_one, 1000000, 1},
31 Cells = [spec_cell(Datum) || Datum <- CellData],
32 Time = ?CHILD(worker, life_time, [X, Y, CellNames]),
33 Children = Cells ++ [Time],
34 {ok, {RestartStrategy, Children}}.
37 spec_cell({_, Name, _}=Datum) ->
41 {Name, {M, F, A}, permanent, 5000, worker, [M]}.