sleepable

package
v0.22.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package sleepable implements a timer that can trigger at or soon after a given time and supports the computer going to sleep while the timer is waiting.

Index

Constants

This section is empty.

Variables

View Source
var MaxSleepTime = 15 * time.Second

MaxSleepTime is the maximum duration the timer will sleep in one interval. Can be overridden for testing.

Functions

This section is empty.

Types

type Timer

type Timer struct {
	C <-chan struct{}
	// contains filtered or unexported fields
}

Timer is a timer that can trigger at or soon after a given time and supports the computer going to sleep while the timer is waiting.

func NewTimer

func NewTimer(nowFunc func() time.Time, until time.Time) *Timer

NewTimer creates a new timer that will trigger at the given time.

func (*Timer) Stop

func (c *Timer) Stop()

Stop stops the timer.

Jump to

Keyboard shortcuts

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