Skip to content

Commit

Permalink
app: simplify sleepCtx
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelkarp committed Nov 14, 2017
1 parent d8c4796 commit d83b49a
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions agent/app/agent_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,8 @@ func (h *handler) runAgent(ctx context.Context) {

// sleepCtx provides a cancelable sleep
func sleepCtx(ctx context.Context, duration time.Duration) {
done := make(chan struct{})
time.AfterFunc(duration, func() {
close(done)
})
select {
case <-ctx.Done():
case <-done:
}
derivedCtx, _ := context.WithDeadline(ctx, time.Now().Add(duration))
<-derivedCtx.Done()
}

type termHandlerIndicator struct {
Expand Down

0 comments on commit d83b49a

Please sign in to comment.