pool

package
v0.25.0-binance.5 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrScheduleTimeout = fmt.Errorf("schedule error: timed out")

ErrScheduleTimeout returned by Pool to indicate that there no free goroutines during some period of time.

Functions

This section is empty.

Types

type Pool

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

Pool contains logic of goroutine reuse.

func NewPool

func NewPool(size, queue, spawn int) *Pool

NewPool creates new goroutine pool with given size. It also creates a work queue of given size. Finally, it spawns given amount of goroutines immediately.

func (*Pool) Schedule

func (p *Pool) Schedule(task func())

Schedule schedules task to be executed over pool's workers.

func (*Pool) ScheduleTimeout

func (p *Pool) ScheduleTimeout(timeout time.Duration, task func()) error

ScheduleTimeout schedules task to be executed over pool's workers. It returns ErrScheduleTimeout when no free workers met during given timeout.

Jump to

Keyboard shortcuts

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