use a buffered channel for quitting
This commit is contained in:
parent
c8202bbc7a
commit
e643525d5c
5
app.go
5
app.go
@ -22,7 +22,7 @@ type App struct {
|
|||||||
func newApp() *App {
|
func newApp() *App {
|
||||||
ui := newUI()
|
ui := newUI()
|
||||||
nav := newNav(ui.wins[0].h)
|
nav := newNav(ui.wins[0].h)
|
||||||
quit := make(chan bool)
|
quit := make(chan bool, 1)
|
||||||
|
|
||||||
return &App{
|
return &App{
|
||||||
ui: ui,
|
ui: ui,
|
||||||
@ -190,8 +190,7 @@ func (app *App) readExpr() chan MultiExpr {
|
|||||||
|
|
||||||
// This is the main event loop of the application. There are two channels to
|
// This is the main event loop of the application. There are two channels to
|
||||||
// read expressions from client and server. Reading and evaluation are done on
|
// read expressions from client and server. Reading and evaluation are done on
|
||||||
// different goroutines except for prompting commands (e.g. "read"). Quitting
|
// different goroutines except for prompting commands (e.g. "read").
|
||||||
// commands should create separate goroutines to prevent deadlock here.
|
|
||||||
func (app *App) handleInp() {
|
func (app *App) handleInp() {
|
||||||
clientChan := app.readExpr()
|
clientChan := app.readExpr()
|
||||||
|
|
||||||
|
4
eval.go
4
eval.go
@ -215,7 +215,7 @@ func (e *CallExpr) eval(app *App, args []string) {
|
|||||||
log.Printf("writing selection file: %s", err)
|
log.Printf("writing selection file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() { app.quit <- true }()
|
app.quit <- true
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -224,7 +224,7 @@ func (e *CallExpr) eval(app *App, args []string) {
|
|||||||
cmd.eval(app, e.args)
|
cmd.eval(app, e.args)
|
||||||
}
|
}
|
||||||
case "quit":
|
case "quit":
|
||||||
go func() { app.quit <- true }()
|
app.quit <- true
|
||||||
case "bot":
|
case "bot":
|
||||||
app.nav.bot()
|
app.nav.bot()
|
||||||
app.ui.loadFile(app.nav)
|
app.ui.loadFile(app.nav)
|
||||||
|
Loading…
Reference in New Issue
Block a user