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:
af47aa3
)
Don't sleep longer than necessary to meet the interval.
author
Siraaj Khandkar
<siraaj@khandkar.net>
Thu, 9 Aug 2012 13:16:35 +0000
(09:16 -0400)
committer
Siraaj Khandkar
<siraaj@khandkar.net>
Thu, 9 Aug 2012 13:16:35 +0000
(09:16 -0400)
003/src/life.erl
patch
|
blob
|
blame
|
history
diff --git
a/003/src/life.erl
b/003/src/life.erl
index
ddb5115
..
f4b1fe5
100644
(file)
--- a/
003/src/life.erl
+++ b/
003/src/life.erl
@@
-7,7
+7,7
@@
-define(CHAR_ALIVE, 111). % "o"
-define(CHAR_BAR, 45). % "-"
--define(INTERVAL, 100).
+-define(
GEN_
INTERVAL, 100).
-record(state, {x :: non_neg_integer()
@@
-73,7
+73,10
@@
life_loop(
,print_time = PrintTime
},
- timer:sleep(?INTERVAL),
+ NewTimeMil = NewTime / 1000,
+ NextGenDelay = round(?GEN_INTERVAL - NewTimeMil),
+ timer:sleep(NextGenDelay),
+
life_loop(NewState).
This page took
0.020642 seconds
and
4
git commands to generate.