Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoundedWaitGroup ¶
type BoundedWaitGroup struct {
// contains filtered or unexported fields
}
BoundedWaitGroup is a wait group which has a limit boundary meaning it will wait for Done() to be called before releasing Add(n) if the limit has been reached.
func NewBoundedWaitGroup ¶
func NewBoundedWaitGroup(cap int) BoundedWaitGroup
NewBoundedWaitGroup returns a new BoundedWaitGroup
func (*BoundedWaitGroup) Add ¶
func (bwg *BoundedWaitGroup) Add(delta int)
Add adds delta, which may be negative, to the BoundedWaitGroup counter. If counter + delta is greater that the cap of the BoundedWaitGroup then Add would block until there is enough slots made available in the the WaitGroup.
func (*BoundedWaitGroup) Done ¶
func (bwg *BoundedWaitGroup) Done()
Done decrements the WaitGroup counter by one.
func (*BoundedWaitGroup) Wait ¶
func (bwg *BoundedWaitGroup) Wait()
Wait blocks until the WaitGroup counter is zero.
type CancelableWaitGroup ¶
type CancelableWaitGroup struct {
// contains filtered or unexported fields
}
CancelableWaitGroup is a Waiter that can be canceled via a context. If the context is canceled then Waiter.Wait() will return even if Waiter.Done() has not been called as much as Waiter.Add(). Note that this waiter can only be used once. If Add() is used after the context has been canceled or after Done() has been called as much as Add() then it will panic.
func NewCancelableWaitGroup ¶
func NewCancelableWaitGroup(context context.Context, cap int) *CancelableWaitGroup
NewCancelableWaitGroup returns a CancelableWaitGroup which has been initialized.
func (*CancelableWaitGroup) Add ¶
func (wg *CancelableWaitGroup) Add(n int)
Add adds n tasks and does not return until wg.cur + n <= wg.cap. However, it does return if the context is canceled.
func (*CancelableWaitGroup) Done ¶
func (wg *CancelableWaitGroup) Done()
Done decreases the number of running tasks.
func (*CancelableWaitGroup) Wait ¶
func (wg *CancelableWaitGroup) Wait()
Wait waits until the number of tasks is 0 or until the context is canceled.