Version: v0.1.15 Latest Latest

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

Go to latest
Published: Jun 19, 2020 License: Apache-2.0 Imports: 2 Imported by: 0




This section is empty.


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.


This section is empty.


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.

Source Files

Jump to

Keyboard shortcuts

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