Documentation
¶
Index ¶
- type TimerCallback
- type TimerManager
- func (tm *TimerManager) ClearTimeout(id int) bool
- func (tm *TimerManager) Initialize()
- func (tm *TimerManager) ProcessTimers()
- func (tm *TimerManager) SetInterval(td time.Duration, arg interface{}, cb TimerCallback) int
- func (tm *TimerManager) SetTimeout(td time.Duration, arg interface{}, cb TimerCallback) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TimerCallback ¶
type TimerCallback func(interface{})
TimerCallback is the type for timer callback functions
type TimerManager ¶
type TimerManager struct {
// contains filtered or unexported fields
}
TimerManager manages multiple timers
func NewTimerManager ¶
func NewTimerManager() *TimerManager
NewTimerManager creates and returns a new timer manager
func (*TimerManager) ClearTimeout ¶
func (tm *TimerManager) ClearTimeout(id int) bool
ClearTimeout clears the timeout specified by the id. Returns true if the timeout is found.
func (*TimerManager) Initialize ¶
func (tm *TimerManager) Initialize()
Initialize initializes the timer manager. It is normally used when the TimerManager is embedded in another type.
func (*TimerManager) ProcessTimers ¶
func (tm *TimerManager) ProcessTimers()
ProcessTimers should be called periodically to process the timers
func (*TimerManager) SetInterval ¶
func (tm *TimerManager) SetInterval(td time.Duration, arg interface{}, cb TimerCallback) int
SetInterval sets a periodic timeout with the specified duration and callback The function returns the timeout id which can be used to cancel the timeout
func (*TimerManager) SetTimeout ¶
func (tm *TimerManager) SetTimeout(td time.Duration, arg interface{}, cb TimerCallback) int
SetTimeout sets a timeout with the specified duration and callback The function returns the timeout id which can be used to cancel the timeout