diff --git a/throttle_timer.go b/throttle_timer.go index 0966e913..38ef4e9a 100644 --- a/throttle_timer.go +++ b/throttle_timer.go @@ -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 }