Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CancelToken ¶
type CancelToken struct {
// contains filtered or unexported fields
}
CancelToken is returned by Register and allows the caller to cancel the timer.
func (*CancelToken) Cancel ¶
func (t *CancelToken) Cancel()
Cancel removes the timer from the clock. Safe to call multiple times.
type Clock ¶
type Clock struct {
// contains filtered or unexported fields
}
Clock manages periodic timers that fire callbacks and publish TimeEvents to the msgbus. All methods are called from the single dispatch thread.
func (*Clock) Register ¶
func (c *Clock) Register(startNs, intervalNs uint64, callback func(event.TimeEvent)) *CancelToken
Register creates a periodic timer that first fires at startNs, then every intervalNs nanoseconds. The callback is invoked directly from the dispatch thread during Tick(). A TimeEvent is also published to the msgbus. Returns a CancelToken to stop the timer.
func (*Clock) Tick ¶
Tick checks all registered timers against nowNs and fires any that are due. For each due timer it calls the callback and publishes a TimeEvent. If multiple intervals have elapsed, each tick is fired individually.
func (*Clock) TimerCount ¶
TimerCount returns the number of active timers.