Documentation
¶
Overview ¶
Package wake reports when the machine resumes from sleep, so subsystems that keep timers or connections can recover from a gap they did not run through.
One detector serves the whole process. It compares how much wall-clock time passed between two of its ticks with how much should have: a process does not run while the machine sleeps, so the first tick after waking lands long after the one before it.
Index ¶
Constants ¶
const Threshold = time.Minute
Threshold is the smallest wall-clock jump that counts as a wake.
Variables ¶
This section is empty.
Functions ¶
func Detect ¶
func Detect(ctx context.Context, ticks <-chan time.Time, interval time.Duration, now func() time.Time, onWake func(slept time.Duration))
Detect is the detector's loop: it reads the clock once to start and once per tick, and calls onWake when a tick lands at least Threshold later than interval allows. Wall-clock time is compared with its monotonic reading stripped, because on most platforms the monotonic clock stops while the machine sleeps and would hide the gap. A clock set forward by hand looks the same, which costs no more than one extra recovery.
Types ¶
This section is empty.