waitgroup

package
v0.0.0-...-14d5243 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 4 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 {
	sync.WaitGroup
}

WaitGroup is a wrapper for sync.WaitGroup

func (*WaitGroup) Run

func (w *WaitGroup) Run(exec func())

Run runs a function in a goroutine, adds 1 to WaitGroup and calls done when function returns.

func (*WaitGroup) RunWithLogger

func (w *WaitGroup) RunWithLogger(exec func(), logger *zap.Logger)

func (*WaitGroup) RunWithRecover

func (w *WaitGroup) RunWithRecover(exec func(), recoverFn func(r interface{}), logger *zap.Logger)

RunWithRecover wraps goroutine startup call with force recovery, add 1 to WaitGroup and call done when function return. it will dump current goroutine stack into log if catch any recover result. exec is that execute logic function. recoverFn is that handler will be called after recover and before dump stack, passing `nil` means noop.

type WaitGroupPool

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

WaitGroupPool is a wrapper for sync.WaitGroup and gp.Pool.

func NewWaitGroupPool

func NewWaitGroupPool(n int, idleDuration time.Duration) *WaitGroupPool

NewWaitGroupPool returns WaitGroupPool.

func (*WaitGroupPool) Close

func (w *WaitGroupPool) Close()

func (*WaitGroupPool) RunWithRecover

func (w *WaitGroupPool) RunWithRecover(exec func(), recoverFn func(r interface{}), logger *zap.Logger)

RunWithRecover runs a function in a goroutine, adds 1 to WaitGroup and calls done when function returns.

Jump to

Keyboard shortcuts

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