Documentation
¶
Overview ¶
Package timers provides safe timer management for event-driven controller components.
SafeTimer wraps *time.Timer with safe stop/drain/reset operations that avoid the common pitfalls of Go timer usage (leaked channels, double-drain races). It is designed for single-goroutine use within select loops.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SafeTimer ¶
type SafeTimer struct {
// contains filtered or unexported fields
}
SafeTimer wraps *time.Timer with safe stop, drain, reset, and channel-get operations. It must only be used from a single goroutine (no internal synchronization).
func (*SafeTimer) Chan ¶
Chan returns the timer's channel, or nil if no timer is active. A nil channel blocks forever in a select, which is the desired behavior when there is no active timer.
func (*SafeTimer) Fired ¶
func (t *SafeTimer) Fired()
Fired should be called when the timer's channel is read in a select case. It clears the internal reference so a new timer can be started.