fixed tick bombs

This commit is contained in:
Stephen McQuay 2013-10-01 21:37:53 -07:00
parent e06f70aed6
commit 158c7d90d8

View File

@ -74,6 +74,7 @@ func NewGame(id string, width, height float64) *game {
func (g *game) run() { func (g *game) run() {
var t0, t1 time.Time var t0, t1 time.Time
payload := NewBoardstate() payload := NewBoardstate()
ticker := time.NewTicker(time.Duration(*tick) * time.Millisecond)
for { for {
select { select {
case <-g.kill: case <-g.kill:
@ -95,7 +96,7 @@ func (g *game) run() {
case s := <-g.sunregister: case s := <-g.sunregister:
delete(g.spectators, s) delete(g.spectators, s)
close(s.send) close(s.send)
case <-time.Tick(time.Duration(*tick) * time.Millisecond): case <-ticker.C:
// XXX: This is very racy!! It was at bottom of loop and empty // XXX: This is very racy!! It was at bottom of loop and empty
// stuff was going out // stuff was going out
payload.EmptySlices() payload.EmptySlices()