cond

package
v0.0.0-...-5720ada Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package cond provides an implementation very similar to sync.Cond, but with support for cancellation due to timeouts, dead tombs, or done contexts. However, one major difference is that Signal() and Broadcast() both require the lock

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
}

func NewCond

func NewCond(l sync.Locker) *Cond

func (*Cond) Broadcast

func (c *Cond) Broadcast()

Broadcast will signal to all waiting threads, if any. Requires L to be locked.

func (*Cond) ContextWait

func (c *Cond) ContextWait(ctx context.Context) bool

ContextWait waits for a signal while the context is not Done. Requires L to be locked. Returns whether it received the signal.

func (*Cond) Signal

func (c *Cond) Signal()

Signal will signal to a waiting thread, if any. Requires L to be locked.

func (*Cond) TimeoutWait

func (c *Cond) TimeoutWait(d time.Duration) bool

TimeoutWait waits for a signal for up to a duration. Requires L to be locked. Returns whether it received the signal.

func (*Cond) TombWait

func (c *Cond) TombWait(t *tomb.Tomb) bool

TombWait waits for a signal while the tomb is not dead. Requires L to be locked. Returns whether it received the signal.

func (*Cond) Wait

func (c *Cond) Wait()

Wait unconditionally waits for a signal. Requires L to be locked.

Jump to

Keyboard shortcuts

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