Documentation
¶
Overview ¶
Package hrtimer is a one-shot timer that fires with sub-millisecond precision. Go's runtime rounds a timer shorter than 1 ms up to 1 ms when every P is idle (it waits in epoll_wait with a millisecond timeout); Flow arms a timerfd-backed asio timer instead (flow/Net2.actor.cpp:2101-2124). The GRV batch window (RFC-259) needs Flow's precision.
A Timer has one owner goroutine that calls Wait. Reset and Stop may be called from any goroutine, including while Wait is parked. Wait can return for an expiry that a later Reset or Stop superseded, so the owner must recheck its own state after every Wait.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("hrtimer: timer closed")
ErrClosed is returned by Wait, Reset and Stop after Close.
var ErrUnsupported = errors.New("hrtimer: unsupported platform")
ErrUnsupported is returned by New on platforms without a precise timer; callers fall back to the runtime's timers.
Functions ¶
This section is empty.
Types ¶
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer is a timerfd read through the netpoller: Wait parks the goroutine without holding a thread or P, and a ready timerfd wakes epoll_wait whatever the runtime's own timeout.
func (*Timer) Reset ¶
Reset arms the timer to expire d from now, replacing any pending expiry. d <= 0 arms the shortest delay, since a zero it_value would disarm it. On error the timer is unchanged.