close timer sooner

pull/467/head^2
Darien Raymond 2017-01-31 12:54:01 +01:00
parent c462e35aad
commit 23a8da215f
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 12 additions and 5 deletions

View File

@ -21,14 +21,21 @@ func (t *ActivityTimer) UpdateActivity() {
func (t *ActivityTimer) run() {
for {
time.Sleep(t.timeout)
select {
case <-t.ctx.Done():
return
case <-t.updated:
default:
case <-time.After(t.timeout):
t.cancel()
return
case <-t.ctx.Done():
return
default:
select {
case <-time.After(t.timeout):
t.cancel()
return
case <-t.ctx.Done():
return
case <-t.updated:
}
}
}
}