gopool

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalConfig = Configure()

Functions

func CloseAndWait

func CloseAndWait()

func Go

func Go(f func(context.Context))

Types

type Config

type Config struct {
	Concurrent  int
	IdleTimeout time.Duration
}

func Configure

func Configure() *Config

func (*Config) Idle

func (c *Config) Idle(time time.Duration) *Config

func (*Config) Workers

func (c *Config) Workers(max int) *Config

type Pool

type Pool struct {
	Cfg *Config
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, cfgs ...*Config) *Pool

func (*Pool) Close

func (g *Pool) Close(grace bool)

Close will call context.Cancel(), so all goroutines maybe exit when job does not complete

func (*Pool) Do

func (g *Pool) Do(f func(context.Context)) *Pool

Do pick one idle goroutine to do the f once

func (*Pool) Done

func (g *Pool) Done()

Done will wait for all goroutines complete the jobs and then close the pool

Jump to

Keyboard shortcuts

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