valuewaiter

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

README

valuewaiter

Go Reference

A Go package that provides a synchronization primitive allowing goroutines to wait for a specific value to be set.

Documentation

Overview

Package valuewaiter provides a synchronization primitive that allows goroutines to wait for a specific value to be set.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ValueWaiter

type ValueWaiter[T comparable] struct {
	// contains filtered or unexported fields
}

ValueWaiter is a synchronization primitive that allows goroutines to wait for a specific value to be set. It is useful for cases where you want to wait for a value to change before proceeding, without busy-waiting.

func NewValueWaiter

func NewValueWaiter[T comparable](initial T) *ValueWaiter[T]

NewValueWaiter creates a new ValueWaiter with an initial value.

func (*ValueWaiter[T]) GetValue

func (vw *ValueWaiter[T]) GetValue() T

GetValue returns the current value of the ValueWaiter.

func (*ValueWaiter[T]) SetValue

func (vw *ValueWaiter[T]) SetValue(v T)

SetValue sets the value of the ValueWaiter and unblocks all calls to WaitValue or WaitValueContext that are waiting for the specified value.

func (*ValueWaiter[T]) WaitValue

func (vw *ValueWaiter[T]) WaitValue(v T)

WaitValue blocks until the ValueWaiter is set to the specified value.

func (*ValueWaiter[T]) WaitValueContext

func (vw *ValueWaiter[T]) WaitValueContext(ctx context.Context, v T) error

WaitValueContext blocks until the ValueWaiter is set to the specified value or the context is cancelled. If the context is cancelled, it returns the context error, otherwise nil.

Jump to

Keyboard shortcuts

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