fixed tick bombs
This commit is contained in:
parent
e06f70aed6
commit
158c7d90d8
3
game.go
3
game.go
@ -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()
|
||||||
|
Loading…
Reference in New Issue
Block a user