Documentation
¶
Overview ¶
Package sync contains a small collection of helpful generic functions and types for synchronization. It is currently part of the public interface and stable, but this may change in future.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LenientWaitGroup ¶
type LenientWaitGroup struct {
// contains filtered or unexported fields
}
LenientWaitGroup implements a lenient wait group for testing purposes based on a `sync.WaitGroup` that allows breaking the barrier by consuming the wait group counter completely without creating panics in consuming components.
func (*LenientWaitGroup) Add ¶
func (wg *LenientWaitGroup) Add(delta int)
Add increments or decrements the wait group counter leniently by the delta, i.e. it does not fail, if the wait group counter is already consumed.
func (*LenientWaitGroup) Done ¶
func (wg *LenientWaitGroup) Done()
Done decrements the wait group counter leniently by one, i.e. it does not fail, if the wait group counter is already consumed.
func (*LenientWaitGroup) Wait ¶
func (wg *LenientWaitGroup) Wait()
Wait waits until the work group counter is completely consumed.
type Synchronizer ¶
type Synchronizer interface {
WaitGroup(WaitGroup)
}
Synchronizer is an interface to setup the wait group of a component.
type WaitGroup ¶
type WaitGroup interface { // Add increments or decrements the wait counter by the given delta. Add(delta int) // Done decrements the wait counter by exactly one. Done() // Wait waits until the wait counter has returned to zero. Wait() }
WaitGroup interface of a wait group as provided by `sync.WaitGroup`.
func NewLenientWaitGroup ¶
func NewLenientWaitGroup() WaitGroup
NewLenientWaitGroup implements a lenient wait group for testing purposes based on a `sync.WaitGroup` that allows breaking the barrier by consuming the wait group counter completely without creating panics in consuming components.