pool: maze.io/x/pool Index | Files

package pool

import "maze.io/x/pool"

Index

Package Files

pool.go

Variables

var (
    DefaultPoolSize    = runtime.NumCPU()
    DefaultPoolWorkers = runtime.NumCPU()
    ErrPoolClosed      = errors.New("broadcast: pool closed")
    ErrScheduleTimeout = errors.New("broadcast: pool schedule timeout")
)

type Pool Uses

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

func New Uses

func New(size, workers int) *Pool

New initialises a new Pool with a backlog of size and a maximum number of workers worker Go routines. The workers spawn on-demand.

func (*Pool) Close Uses

func (pool *Pool) Close() error

Close stops accepting new work and interrupts the workers as soon as they finish the work they are currently processing.

func (*Pool) Schedule Uses

func (pool *Pool) Schedule(work func()) error

Schedule work. If no worker is available or if there is no room in the worker channel, this call will block.

func (*Pool) ScheduleUntil Uses

func (pool *Pool) ScheduleUntil(work func(), timeout time.Duration) error

ScheduleUntil schedules work with a timeout. If no worker is available or if there is no room within the specified timeout, an error is returned.

func (*Pool) Spawn Uses

func (pool *Pool) Spawn(n int) error

Spawn pre-spawns n workers. Calling this function more than once when the total of spawned workers exceed the queue size will block until work is freed from the schedule.

Package pool imports 5 packages (graph). Updated 2018-12-02. Refresh now. Tools for package owners.