cond

package
v3.2.4-0...-ee2403e Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cond

type Cond struct {
	L sync.Locker
	// contains filtered or unexported fields
}

Cond is a conditional variable implementation that uses channels for notifications. It only supports .Broadcast() method, however supports timeout based Wait() calls unlike regular sync.Cond.

func New

func New(l sync.Locker) *Cond

func (*Cond) Broadcast

func (c *Cond) Broadcast()

Broadcast notifies all waiting goroutines that something has changed.

func (*Cond) NotifyChan

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

NotifyChan returns a channel that can be used to wait for next Broadcast() call.

func (*Cond) Wait

func (c *Cond) Wait()

Wait waits for Broadcast calls. Similar to regular sync.Cond, this unlocks the underlying locker first, waits on changes and re-locks it before returning.

func (*Cond) WaitWithTimeout

func (c *Cond) WaitWithTimeout(t time.Duration)

WaitWithTimeout is same as Wait() call, but will only wait up to a given timeout.

Jump to

Keyboard shortcuts

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