spin

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package spin provides objects for assisting with sleeping while waiting for an action to become available. This is useful in preventing CPU starvation when there is nothing to do.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sleeper

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

Sleeper allows sleeping for an increasing time period up to 1 second after giving up a goroutine 2^16 times. This is not thread-safe and should be thrown away once the loop the calls it is able to perform its function.

func (*Sleeper) Sleep

func (s *Sleeper) Sleep()

Sleep at minimum allows another goroutine to be scheduled and after 2^16 calls will begin to sleep from 1 nanosecond to 1 second, with each call raising the sleep time by a multiple of 10.

Jump to

Keyboard shortcuts

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