Documentation ¶
Overview ¶
Package syncutil contains advanced synchronization primitives.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Any ¶
type Any struct {
// contains filtered or unexported fields
}
Any calls a group of functions in separate goroutines, and checks that at least one function call succeeded. The Wait method returns an error if (and only if) all calls to Go have failed. Compare to https://pkg.go.dev/golang.org/x/sync/errgroup.
A zero-value Any is valid. Any must not be copied after first use.
func AnyWithContext ¶ added in v0.0.2
AnyWithContext returns a new Any and an associated Context derived from ctx.
The derived Context is canceled the first time a function passed to Go succeeds (returns a nil error) or the first time Wait returns, whichever occurs first.
type BarrierChan ¶ added in v0.0.5
type BarrierChan struct {
// contains filtered or unexported fields
}
func NewBarrierChan ¶ added in v0.0.5
func NewBarrierChan(n uint32) BarrierChan
func (BarrierChan) Done ¶ added in v0.0.5
func (b BarrierChan) Done() <-chan struct{}
func (BarrierChan) Signal ¶ added in v0.0.8
func (b BarrierChan) Signal(finalize func()) (ready bool)
func (BarrierChan) SignalAndWait ¶ added in v0.0.5
func (b BarrierChan) SignalAndWait(finalize func())
type Breaker ¶
type Breaker struct {
// contains filtered or unexported fields
}
A Breaker calls functions in separate goroutines, returning a nil error if one succeeds. Contrary to 'Any', calls to 'Wait" will block until either a function returns a nil error or all inflight functions have returned errors.
The zero-value Breaker is ready to use.
func BreakerWithContext ¶ added in v0.0.2
BreakerWithContext returns a Breaker and an associated context derived from ctx.
The derived Context is canceled the first time a function passed to Go succeeds (returns a nil error) or the first time Wait returns, whichever occurs first.
func (*Breaker) Break ¶
func (b *Breaker) Break()
Break renders each subsequent calls to 'Go' a nop. Aftr 'Break' returns, 'Wait' will block until all in-flight functions have returned.
type Ctr ¶
type Ctr uint32
Ctr is a 32-bit, lock-free counter
func (*Ctr) Int ¶ added in v0.0.11
Int atomically loads the value as an untyped integer. This is useful for integer comparisons, e.g. with `len`.
type Ctr64 ¶ added in v0.0.11
type Ctr64 uint64
Ctr64 is a 64-bit, lock-free counter
func (*Ctr64) Int ¶ added in v0.0.11
Int atomically loads the value as an untyped integeger. This is useful for integer comparisons, e.g. with `len`.
type FuncGroup ¶
FuncGroup calls a group of functions in separate goroutines and waits until they have all returned. Compare to https://pkg.go.dev/golang.org/x/sync/errgroup.
A zero-value FuncGroup is valid. FuncGroup must not be copied after first use.
type Join ¶ added in v0.0.4
type Join struct {
// contains filtered or unexported fields
}
Join calls a group of functions in separate goroutines and waits until they have all returned. The error returned by Join is a go.uber.org/multierr and is non-nil if any function returned a non-nil error.
Unlike pkg.go.dev/golang.org/x/sync/errgroup, Join does not return until the full set uf goroutines has finished
A zero-value Join is valid. Join must not be copied after first use.