21 lines
407 B
Go
21 lines
407 B
Go
package throttling
|
|
|
|
import "time"
|
|
|
|
// Same as Throttler above but multi-thread safe and
|
|
// using a event loop to scheduole notifications. THis runs its own
|
|
// go routine for scheduling
|
|
|
|
type _clock interface {
|
|
time() time.Time
|
|
}
|
|
|
|
type systemClock struct{}
|
|
|
|
func (clock systemClock) time() time.Time {
|
|
return time.Now()
|
|
}
|
|
|
|
// Default clock, can be overriden in test cases.
|
|
var clock _clock = systemClock{}
|