Skip to content

Commit

Permalink
pin add: use a Ticker instead of a Timer
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Kevin Atkinson <[email protected]>
  • Loading branch information
kevina committed Feb 15, 2017
1 parent 5f00d7b commit e530d19
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/commands/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ var addPinCmd = &cmds.Command{
out := make(chan interface{})
res.SetOutput((<-chan interface{})(out))
go func() {
ticker := time.NewTicker(500 * time.Millisecond)
defer ticker.Stop()
defer close(out)
for {
timer := time.NewTimer(500 * time.Millisecond)
defer timer.Stop()
select {
case val, ok := <-ch:
if !ok {
Expand All @@ -108,7 +108,7 @@ var addPinCmd = &cmds.Command{
}
out <- &AddPinOutput{Progress: -1, Pins: val}
return
case <-timer.C:
case <-ticker.C:
out <- &AddPinOutput{Progress: v.Value()}
case <-ctx.Done():
res.SetError(ctx.Err(), cmds.ErrNormal)
Expand Down

0 comments on commit e530d19

Please sign in to comment.