home
/
code
/
cellular-automata.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
c8c7564
)
Using erlang:send_after/3 for tick scheduling.
author
Siraaj Khandkar
<siraaj@khandkar.net>
Mon, 30 Jul 2012 02:26:41 +0000
(22:26 -0400)
committer
Siraaj Khandkar
<siraaj@khandkar.net>
Mon, 30 Jul 2012 02:26:41 +0000
(22:26 -0400)
001/src/life_time.erl
patch
|
blob
|
blame
|
history
diff --git
a/001/src/life_time.erl
b/001/src/life_time.erl
index
089925f
..
1140c79
100644
(file)
--- a/
001/src/life_time.erl
+++ b/
001/src/life_time.erl
@@
-56,7
+56,6
@@
report_state(CellID, GenID, CellState) ->
%% ============================================================================
handle_call(_Msg, _From, State) -> {reply, ok, State}.
%% ============================================================================
handle_call(_Msg, _From, State) -> {reply, ok, State}.
-handle_info(_Msg, State) -> {noreply, State}.
code_change(_Old, State, _Other) -> {ok, State}.
terminate(_Reason, State) -> {ok, State}.
code_change(_Old, State, _Other) -> {ok, State}.
terminate(_Reason, State) -> {ok, State}.
@@
-78,7
+77,7
@@
init([X, Y, Cells]) ->
{ok, State}.
{ok, State}.
-handle_
cast
(next_gen,
+handle_
info
(next_gen,
#state{cells=Cells
,num_cells=NumCells
,state_pairs=[]
#state{cells=Cells
,num_cells=NumCells
,state_pairs=[]
@@
-94,6
+93,10
@@
handle_cast(next_gen,
},
{noreply, NewState};
},
{noreply, NewState};
+handle_info(_Msg, State) ->
+ {noreply, State}.
+
+
handle_cast({report_state, {CellID, GenID, CellState}},
#state{x=X
,y=Y
handle_cast({report_state, {CellID, GenID, CellState}},
#state{x=X
,y=Y
@@
-129,7
+132,7
@@
handle_cast({report_state, {CellID, GenID, CellState}},
),
ok = do_print_bar(X),
ok = do_print_state_chars(X, StateChars),
),
ok = do_print_bar(X),
ok = do_print_state_chars(X, StateChars),
- ok = timer:sleep(?INTERVAL),
+
ok = schedule_next_gen(),
{noreply, NewState#state{state_pairs=[]}};
ok = schedule_next_gen(),
{noreply, NewState#state{state_pairs=[]}};
@@
-150,7
+153,8
@@
increment_dead_or_alive(1, NDead, NAlive) -> {NDead, NAlive + 1}.
schedule_next_gen() ->
schedule_next_gen() ->
- ok = gen_server:cast(?MODULE, next_gen).
+ erlang:send_after(?INTERVAL, self(), next_gen),
+ ok.
state_to_char(0) -> ?CHAR_DEAD;
state_to_char(0) -> ?CHAR_DEAD;
This page took
0.033097 seconds
and
4
git commands to generate.