ctxsync

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 3 Imported by: 5

Documentation

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 a condition variable that implements a context-aware Wait.

func NewCond

func NewCond(l sync.Locker) *Cond

NewCond returns a new ContextCond based on Locker l.

func (*Cond) Broadcast

func (c *Cond) Broadcast()

Broadcast notifies waiters of a state change. Broadcast must only be called while the cond's lock is held.

func (*Cond) Done

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

Done returns a channel that is closed after the next broadcast of this Cond. Done must be called with the Cond's lock held; the lock is released before Done returns.

func (*Cond) Wait

func (c *Cond) Wait(ctx context.Context) error

Wait returns after the next call to Broadcast, or if the context is complete. The context's lock must be held when calling Wait. An error returns with the context's error if the context completes while waiting.

type Mutex added in v0.0.11

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

Mutex is a context-aware mutex. It must not be copied. The zero value is ready to use.

func (*Mutex) Lock added in v0.0.11

func (m *Mutex) Lock(ctx context.Context) error

Lock attempts to exclusively lock m. If the m is already locked, it will wait until it is unlocked. If ctx is canceled before the lock can be taken, Lock will not take the lock, and a non-nil error is returned.

func (*Mutex) Unlock added in v0.0.11

func (m *Mutex) Unlock()

Unlock unlocks m. It must be called exactly once iff Lock returns nil. Unlock panics if it is called while m is not locked.

Jump to

Keyboard shortcuts

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