mirror of https://github.com/jroimartin/gocui.git
_examples/goroutine.go: simpler shutdown logic
This commit is contained in:
parent
7ac95c981b
commit
c690b943b6
|
@ -16,7 +16,7 @@ import (
|
||||||
const NumGoroutines = 10
|
const NumGoroutines = 10
|
||||||
|
|
||||||
var (
|
var (
|
||||||
done = make(chan bool)
|
done = make(chan struct{})
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
|
||||||
mu sync.Mutex // protects ctr
|
mu sync.Mutex // protects ctr
|
||||||
|
@ -66,9 +66,7 @@ func keybindings(g *gocui.Gui) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func quit(g *gocui.Gui, v *gocui.View) error {
|
func quit(g *gocui.Gui, v *gocui.View) error {
|
||||||
for i := 0; i < NumGoroutines; i++ {
|
close(done)
|
||||||
done <- true
|
|
||||||
}
|
|
||||||
return gocui.ErrQuit
|
return gocui.ErrQuit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue