goroutine_pool

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoroutinePool

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

GoroutinePool is a goroutine pool.

func NewGoroutinePool

func NewGoroutinePool(maxGoroutineCount int) *GoroutinePool

NewGoroutinePool returns a new goroutine pool. If the max goroutine count is 0, it means no limit.

func NewGoroutinePoolWithoutLimit

func NewGoroutinePoolWithoutLimit() *GoroutinePool

NewGoroutinePoolWithoutLimit returns a new goroutine pool without limit.

func (*GoroutinePool) CurrentGoroutineCount

func (pool *GoroutinePool) CurrentGoroutineCount() int

CurrentGoroutineCount returns the current goroutine count of the pool.

func (*GoroutinePool) Go

func (pool *GoroutinePool) Go(worker func(context.Context) error)

Go adds a new worker to the pool.

func (*GoroutinePool) MaxGoroutineCount

func (pool *GoroutinePool) MaxGoroutineCount() int

MaxGoroutineCount returns the max goroutine count of the pool. If the max goroutine count is 0, it means no limit.

func (*GoroutinePool) Wait

func (pool *GoroutinePool) Wait(ctx context.Context) error

Wait waits for all workers to finish. If any worker returns an error, it will return the error.

Jump to

Keyboard shortcuts

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