home
/
code
/
cellular-automata.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed out-of-order message handling.
[cellular-automata.git]
/
001
/
src
/
life_time.erl
diff --git
a/001/src/life_time.erl
b/001/src/life_time.erl
index
b47073c
..
49ab646
100644
(file)
--- a/
001/src/life_time.erl
+++ b/
001/src/life_time.erl
@@
-4,7
+4,7
@@
%% API
-export([start_link/3
%% API
-export([start_link/3
- ,report_state/
2
+ ,report_state/
3
]).
%% Callbacks
]).
%% Callbacks
@@
-45,8
+45,8
@@
start_link(X, Y, Cells) ->
gen_server:start_link(ServerName, ?MODULE, Args, Opts).
gen_server:start_link(ServerName, ?MODULE, Args, Opts).
-report_state(CellID, CellState) ->
- gen_server:cast(?MODULE, {report_state, {CellID, CellState}}).
+report_state(CellID,
GenID,
CellState) ->
+ gen_server:cast(?MODULE, {report_state, {CellID,
GenID,
CellState}}).
%% ============================================================================
%% ============================================================================
@@
-89,7
+89,7
@@
handle_cast(next_gen,
ok = cast_all(Cells, {next_gen, NewGenID}),
{noreply, State#state{replies_pending=NumCells, gen_id=NewGenID}};
ok = cast_all(Cells, {next_gen, NewGenID}),
{noreply, State#state{replies_pending=NumCells, gen_id=NewGenID}};
-handle_cast({report_state, {ID, CellState}},
+handle_cast({report_state, {
CellID, Gen
ID, CellState}},
#state{x=X
,y=Y
,state_pairs=StatePairs
#state{x=X
,y=Y
,state_pairs=StatePairs
@@
-98,7
+98,7
@@
handle_cast({report_state, {ID, CellState}},
,num_cells=NumCells
}=State) ->
,num_cells=NumCells
}=State) ->
- NewStatePairs = [{ID, CellState} | StatePairs],
+ NewStatePairs = [{
Cell
ID, CellState} | StatePairs],
NewRepliesPending = RepliesPending - 1,
NewState = State#state{replies_pending=NewRepliesPending},
NewRepliesPending = RepliesPending - 1,
NewState = State#state{replies_pending=NewRepliesPending},
@@
-115,9
+115,7
@@
handle_cast({report_state, {ID, CellState}},
[X, Y, NumCells, GenID]
),
ok = do_print_bar(X),
[X, Y, NumCells, GenID]
),
ok = do_print_bar(X),
-
ok = do_print_state_chars(X, StateChars),
ok = do_print_state_chars(X, StateChars),
-
ok = timer:sleep(?INTERVAL),
schedule_next_gen(),
{noreply, NewState#state{state_pairs=[]}};
ok = timer:sleep(?INTERVAL),
schedule_next_gen(),
{noreply, NewState#state{state_pairs=[]}};
This page took
0.023863 seconds
and
4
git commands to generate.