Skip to content

Commit

Permalink
Implement new auto close feature, so tha the process doesn't stay in …
Browse files Browse the repository at this point in the history
…the background after your editor has been closed and/or is not using it anymore
  • Loading branch information
Matias Surdi committed May 21, 2016
1 parent efb3d40 commit e112123
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions server.go
Expand Up @@ -11,6 +11,7 @@ import (
"path/filepath"
"reflect"
"runtime"
"time"
)

func do_server() int {
Expand Down Expand Up @@ -96,17 +97,24 @@ func (this *daemon) loop() {
conn_in <- c
}
}()

timeout := time.Duration(g_config.CloseTimeout) * time.Second
countdown := time.NewTimer(timeout)

for {
// handle connections or server CMDs (currently one CMD)
select {
case c := <-conn_in:
rpc.ServeConn(c)
countdown.Reset(timeout)
runtime.GC()
case cmd := <-this.cmd_in:
switch cmd {
case daemon_close:
return
}
case <-countdown.C:
return
}
}
}
Expand Down

0 comments on commit e112123

Please sign in to comment.