Updated references from old to new module names.
[cellular-automata.git] / 001 / src / life_god.erl
CommitLineData
982ec720 1-module(life_god).
d2a0e2f9
SK
2-behaviour(supervisor).
3
4
5%% API
6-export([start_link/2]).
7
8%% Callbacks
9-export([init/1]).
10
11
12%% Helper macro for declaring children of supervisor
13-define(CHILD(Type, I, Args), {I, {I, start_link, Args}, permanent, 5000, Type, [I]}).
14
15
16%% ============================================================================
17%% API
18%% ============================================================================
19
20start_link(X, CellData) ->
21 supervisor:start_link({local, ?MODULE}, ?MODULE, [X, CellData]).
22
23
24%% ============================================================================
25%% Callbacks
26%% ============================================================================
27
28init([X, CellData]) ->
29 CellNames = [Name || {_, Name, _} <- CellData],
30 RestartStrategy = {one_for_one, 5, 10},
31 Cells = [spec_cell(Datum) || Datum <- CellData],
982ec720 32 Time = ?CHILD(worker, life_time, [X, CellNames]),
d2a0e2f9
SK
33 Children = Cells ++ [Time],
34 {ok, {RestartStrategy, Children}}.
35
36
37spec_cell({_, Name, _}=Datum) ->
982ec720 38 M = life_cell,
d2a0e2f9
SK
39 F = start_link,
40 A = [Datum],
41 {Name, {M, F, A}, permanent, 5000, worker, [M]}.
42
43 %{ID, {ID, start_link, Args}, permanent, 5000, Type, [ID]}.
44
45
46
47
This page took 0.026304 seconds and 4 git commands to generate.