Browse Source

Fix ThrottleTimer null-pointer error / race condition

pull/1842/head
Jae Kwon 8 years ago
parent
commit
70e694ee76
1 changed files with 2 additions and 0 deletions
  1. +2
    -0
      throttle_timer.go

+ 2
- 0
throttle_timer.go View File

@ -26,7 +26,9 @@ func NewThrottleTimer(name string, dur time.Duration) *ThrottleTimer {
var ch = make(chan struct{})
var quit = make(chan struct{})
var t = &ThrottleTimer{Name: name, Ch: ch, dur: dur, quit: quit}
t.mtx.Lock()
t.timer = time.AfterFunc(dur, t.fireRoutine)
t.mtx.Unlock()
t.timer.Stop()
return t
}


Loading…
Cancel
Save