Documentation
¶
Overview ¶
Package timer implements a hierarchical timer wheel for efficient timeout management in event-driven I/O engines.
Index ¶
Constants ¶
View Source
const ( // WheelSize is the number of slots in the timer wheel (power of 2 for fast modulo). WheelSize = 8192 // TickInterval is the granularity of the timer wheel. TickInterval = 100 * time.Millisecond )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
FD int
Deadline int64 // unix nano
Kind TimeoutKind
// contains filtered or unexported fields
}
Entry represents a scheduled timeout.
type TimeoutKind ¶
type TimeoutKind uint8
TimeoutKind identifies the type of timeout.
const ( ReadTimeout TimeoutKind = iota WriteTimeout IdleTimeout )
Timeout kinds for the timer wheel.
type Wheel ¶
type Wheel struct {
// contains filtered or unexported fields
}
Wheel is a hashed timer wheel with O(1) schedule and cancel.
func New ¶
func New(onExpire func(fd int, kind TimeoutKind)) *Wheel
New creates a timer wheel that calls onExpire for each expired entry.
Click to show internal directories.
Click to hide internal directories.