concurrency

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2018 License: Apache-2.0 Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WorkerPool

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

WorkerPool is a pool of workers that manages a number of goroutines to run some tasks concurrently.

func NewWorkerPool

func NewWorkerPool(threads int) *WorkerPool

NewWorkerPool returns a new worker pool. This call will never block. This function creates a set of <thread> goroutines that watch the list of tasks that the worker pool has been assigned to do.

func (*WorkerPool) Do

func (pool *WorkerPool) Do(fn func())

Do tells the worker pool to start executing a task. This call may block if the workers in the pool are all busy.

func (*WorkerPool) Stop

func (pool *WorkerPool) Stop()

Stop tells the worker pool to stop its goroutines, potentially losing some of its tasks while they are in the queue.

func (*WorkerPool) Wait

func (pool *WorkerPool) Wait()

Wait waits for stop or all tasks are done.

Jump to

Keyboard shortcuts

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