pool

package
v0.0.0-...-2d572df Latest Latest
Warning

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

Go to latest
Published: May 28, 2021 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 Config

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

Config holds the configuration for an async implementation of a Pool with configurable concurrency and channel buffer.

func New

func New(concurrency, buffer int) *Config

New returns a new pool.Config ready to be started and added to concurrency sets the number of workers, buffer sets the maximum backlog before pushing to the queue would block

func (*Config) Add

func (c *Config) Add(f func()) bool

Add pushes a function to the pool for processing

func (*Config) Start

func (c *Config) Start() Pool

Start kicks off the worker pool

func (*Config) Stop

func (c *Config) Stop()

Stop closes the pool and drains it

type Pool

type Pool interface {
	Add(func()) bool
	Start() Pool
	Stop()
}

Pool implements a generic worker queue to which arbitrary functions can be pushed to for asynchronous processing

Jump to

Keyboard shortcuts

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