|
|
@@ -1,6 +1,7 @@ |
|
|
package tickevent |
|
|
package tickevent |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
|
|
|
"math/rand" |
|
|
"sync/atomic" |
|
|
"sync/atomic" |
|
|
"time" |
|
|
"time" |
|
|
) |
|
|
) |
|
|
@@ -48,7 +49,7 @@ func (e *Executor[TArgs]) Start(event TickEvent[TArgs], intervalMs int, opts ... |
|
|
|
|
|
|
|
|
go func() { |
|
|
go func() { |
|
|
if opt.RandomStartDelayMs > 0 { |
|
|
if opt.RandomStartDelayMs > 0 { |
|
|
<-time.After(time.Duration(opt.RandomStartDelayMs) * time.Millisecond) |
|
|
|
|
|
|
|
|
<-time.After(time.Duration(rand.Intn(opt.RandomStartDelayMs)) * time.Millisecond) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
timeTicker := time.NewTicker(time.Duration(intervalMs) * time.Millisecond) |
|
|
timeTicker := time.NewTicker(time.Duration(intervalMs) * time.Millisecond) |
|
|
|