pool

package
v0.25.0-binance.19 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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