power

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 2 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 power holds one serialized native idle-sleep request while the Node's power setting is on and the Node has running work.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	Supported() bool
	Held() bool
	Acquire() int64
	Release() int64
}

Backend is the system's idle-sleep request. Acquire and Release return the system's error code, 0 for success.

func Unsupported

func Unsupported() Backend

Unsupported is the backend of a system without an idle-sleep request.

type Service

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

Service keeps the system awake while the setting is on and work is held.

func New

func New(failed func(int64)) *Service

New creates the service over the system's request; failed receives the first system error.

func WithBackend

func WithBackend(backend Backend, failed func(int64)) *Service

WithBackend creates the service over backend.

func (*Service) Apply

func (s *Service) Apply(settings protocol.PowerSettings)

Apply takes the saved settings. Replayed durable results and delayed readers cannot restore an older policy.

func (*Service) Close

func (s *Service) Close()

Close releases the request for good.

func (*Service) Hold

func (s *Service) Hold() func()

Hold counts one piece of running work until the returned function is called.

func (*Service) Status

func (s *Service) Status() Status

Status reports what the service holds.

type Status

type Status struct {
	Enabled   bool
	Acquired  bool
	Supported bool
	Closed    bool
	Error     int64 // the first system error, 0 for none
}

Status is what the service holds now.

Jump to

Keyboard shortcuts

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