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
|
||||
|
||||
var (
|
||||
done = make(chan bool)
|
||||
done = make(chan struct{})
|
||||
wg sync.WaitGroup
|
||||
|
||||
mu sync.Mutex // protects ctr
|
||||
|
@ -66,9 +66,7 @@ func keybindings(g *gocui.Gui) error {
|
|||
}
|
||||
|
||||
func quit(g *gocui.Gui, v *gocui.View) error {
|
||||
for i := 0; i < NumGoroutines; i++ {
|
||||
done <- true
|
||||
}
|
||||
close(done)
|
||||
return gocui.ErrQuit
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue