awakeclock

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package awakeclock measures time the system was awake. Watchdogs use it so a laptop asleep past a deadline isn't treated as a hung process.

Index

Constants

View Source
const SleptThreshold = 5 * time.Minute

SleptThreshold is how far wall time may run ahead of awake time before a wait counts as having spanned a sleep.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Awake() time.Duration
	Wall() time.Time
}

Clock reads awake time (excluding system sleep) and wall time.

var System Clock = systemClock{}

System is the real clock.

type Deadline

type Deadline struct {
	// contains filtered or unexported fields
}

Deadline is a start point on a Clock.

func Begin

func Begin(clk Clock) Deadline

Begin starts a deadline now.

func (Deadline) Wait

func (d Deadline) Wait(limit time.Duration, done <-chan struct{}, step time.Duration) (fired, slept bool)

Wait blocks until limit of awake time has passed since Begin (fired) or done is closed, polling every step. slept reports that wall time ran ahead of awake time by more than SleptThreshold meanwhile.

Jump to

Keyboard shortcuts

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