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 (parent:
b699b8a
)
Better function names.
author
Siraaj Khandkar
<siraaj@khandkar.net>
Sat, 28 Jul 2012 17:51:00 +0000
(13:51 -0400)
committer
Siraaj Khandkar
<siraaj@khandkar.net>
Sat, 28 Jul 2012 17:51:00 +0000
(13:51 -0400)
001/src/life_cell.erl
patch
|
blob
|
blame
|
history
diff --git
a/001/src/life_cell.erl
b/001/src/life_cell.erl
index
2ebdf7b
..
a77e279
100644
(file)
--- a/
001/src/life_cell.erl
+++ b/
001/src/life_cell.erl
@@
-75,11
+75,11
@@
handle_cast({next_gen, GenID},
,early_msgs=EarlyMsgs
}=State) ->
,early_msgs=EarlyMsgs
}=State) ->
- ok = cast_all(Neighbors, {state_broadcast, GenID, CellState}),
+ ok = cast_
one2
all(Neighbors, {state_broadcast, GenID, CellState}),
% Put stashed messages back in the mailbox,
% now that we're ready to handle them
% Put stashed messages back in the mailbox,
% now that we're ready to handle them
- ok = cast_
to
(Name, EarlyMsgs),
+ ok = cast_
all2one
(Name, EarlyMsgs),
NewState = State#state{replies_pending=NumNeighbors
,gen_id=GenID
NewState = State#state{replies_pending=NumNeighbors
,gen_id=GenID
@@
-147,18
+147,18
@@
handle_info(_Msg, State) ->
%% Internal
%% ============================================================================
%% Internal
%% ============================================================================
-% Cast
different messages to a singl
e destination
-cast_
to
(_, []) -> ok;
-cast_
to
(Server, [Msg | Msgs]) ->
+% Cast
all messages to on
e destination
+cast_
all2one
(_, []) -> ok;
+cast_
all2one
(Server, [Msg | Msgs]) ->
ok = gen_server:cast(Server, Msg),
ok = gen_server:cast(Server, Msg),
- cast_
to
(Server, Msgs).
+ cast_
all2one
(Server, Msgs).
-% Cast
the same message to multiple
destinations
-cast_all([], _) -> ok;
-cast_all([Server | Servers], Msg) ->
+% Cast
one message to all
destinations
+cast_
one2
all([], _) -> ok;
+cast_
one2
all([Server | Servers], Msg) ->
ok = gen_server:cast(Server, Msg),
ok = gen_server:cast(Server, Msg),
- cast_all(Servers, Msg).
+ cast_
one2
all(Servers, Msg).
new_state(1, LiveNeighbors) when LiveNeighbors < 2 -> 0;
new_state(1, LiveNeighbors) when LiveNeighbors < 2 -> 0;
This page took
0.037763 seconds
and
4
git commands to generate.