trigger

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: BSD-3-Clause Imports: 1 Imported by: 1

Documentation

Overview

Package trigger implements an edge-triggered condition variable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cond

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

A Cond is an edge-triggered condition shared by multiple goroutines. The Cond.Ready method returns a channel that is closed when the condition is activated.

When a condition is first created it is inactive. It remains inactive until Cond.Set or Cond.Signal is called, either of which causes the current ready channel to be closed. Once a condition has been activated, it remains active until it is reset. Use Cond.Reset to make it inactive.

The Cond.Signal method activates and then immediately resets the condition, acting as Set and Reset done in a single step.

A zero Cond is ready for use, and is inactive, but must not be copied after any of its methods have been called.

func New

func New() *Cond

New constructs a new inactive Cond.

func (*Cond) Ready

func (c *Cond) Ready() <-chan struct{}

Ready returns a channel that is closed when t is activated. If t is active when Ready is called, the returned channel will already be closed.

func (*Cond) Reset

func (c *Cond) Reset()

Reset resets the condition. If it was already inactive, Reset has no effect.

func (*Cond) Set

func (c *Cond) Set()

Set activates the condition. If it was already active, Set has no effect.

func (*Cond) Signal

func (c *Cond) Signal()

Signal activates and immediately resets the condition. If the condition was already active, this is equivalent to Cond.Reset.

Jump to

Keyboard shortcuts

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