waitgroup

package
v1.6.6 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WaitGroup

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

WaitGroup waits for other same processes based key with timeout.

func New

func New(timeout time.Duration) *WaitGroup

New return a new WaitGroup with timeout.

func (*WaitGroup) Add

func (wg *WaitGroup) Add(key uint64)

(*WaitGroup).Add add adds a new caller or if the caller exists increment dups with key.

func (*WaitGroup) Done

func (wg *WaitGroup) Done(key uint64)

(*WaitGroup).Done done cancels the group context or if the caller dups more then zero, decrements the dups with key.

func (*WaitGroup) Get

func (wg *WaitGroup) Get(key uint64) int

(*WaitGroup).Get get return count of dups with key.

func (*WaitGroup) Join added in v1.6.4

func (wg *WaitGroup) Join(key uint64) <-chan struct{}

Join atomically decides leadership for key. It returns nil and registers the caller as the leader (caller must call Done when finished). If a leader already exists, Join returns a channel that closes when the leader finishes; followers must NOT call Done — they never registered as a participant, so calling Done would either over-decrement the dup counter or cancel the leader's context out from under it.

This API closes the Wait-then-Add race in the older Wait/Add sequence: two simultaneous first callers both saw "no leader" and both became leaders, so the dedup didn't actually dedup.

func (*WaitGroup) Wait

func (wg *WaitGroup) Wait(key uint64)

(*WaitGroup).Wait wait blocks until WaitGroup context cancelled or timedout with key.

Jump to

Keyboard shortcuts

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