syncwg

package
v1.50.1-cluster Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: Apache-2.0 Imports: 1 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WaitGroup

type WaitGroup struct {
	sync.WaitGroup
	// contains filtered or unexported fields
}

WaitGroup wraps sync.WaitGroup and makes safe to call Add/Wait from concurrent goroutines.

An additional limitation is that call to Wait prohibits further calls to Add until return.

func (*WaitGroup) Add

func (wg *WaitGroup) Add(n int)

Add registers n additional workers. Add may be called from concurrent goroutines.

func (*WaitGroup) Wait

func (wg *WaitGroup) Wait()

Wait waits until all the goroutines call Done.

Wait may be called from concurrent goroutines.

Further calls to Add are blocked until return from Wait.

func (*WaitGroup) WaitAndBlock

func (wg *WaitGroup) WaitAndBlock()

WaitAndBlock waits until all the goroutines call Done and then prevents from new goroutines calling Add.

Further calls to Add are always blocked. This is useful for graceful shutdown when other goroutines calling Add must be stopped.

wg cannot be used after this call.

Jump to

Keyboard shortcuts

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