routines

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

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

Pool is a FIFO go-routine work pool. Work can be scheduled and is executed by the first free worker in the pool. Scheduled work is executed in queueing order.

func NewPool

func NewPool(routines uint) *Pool

NewPool creates and start a new go-routine pool. The pool starts <routines> number of workers.

func (*Pool) Queue

func (p *Pool) Queue(workFn WorkFn)

Queue queues new work for the pool. If Queue() is called after Wait(), the method panics. The method never blocks.

func (*Pool) Wait

func (p *Pool) Wait()

Wait waits until the workqueue is empty and then terminates the worker goroutines. The method can be called safely multiple times. After Wait() was called, no further work must be queued.

type WorkFn

type WorkFn func()

WorkFn is a function that is executed by the pool workers.

Jump to

Keyboard shortcuts

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