clock

package
v1.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AfterWallClock

func AfterWallClock(d time.Duration) <-chan time.Time

AfterWallClock returns a channel that receives after duration d, measured against wall-clock time. Unlike time.After, it is resilient to the system clock jumping forward (e.g. after a suspend/resume cycle): a second ticker fires every second so a large wall-clock jump is detected within 1 s.

Previous implementation spawned a goroutine containing both time.After AND time.NewTicker, i.e. two OS timers per call. The new implementation uses only time.NewTicker and checks elapsed wall-clock time on each tick, which achieves the same goal with one timer and no goroutine leak on the fast path (when the deadline has already passed before the first tick).

func RunTicker

func RunTicker(ctx context.Context, interval, retryInterval time.Duration, cb func(context.Context) error)

RunTicker calls cb in a loop, waiting interval between successful calls and retryInterval after a failure. It stops when ctx is cancelled.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL