work

package
v0.0.0-...-d6aaa9e Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Example provided with help from Jason Waldrip. Package work manages a pool of goroutines to perform work.

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 provides a pool of goroutines that can execute any Worker tasks that are submitted.

func New

func New(maxGoroutines int) *Pool

New creates a new work pool.

func (*Pool) Run

func (p *Pool) Run(w Worker)

Run submits work to the pool.

func (*Pool) Shutdown

func (p *Pool) Shutdown()

Shutdown waits for all the goroutines to shutdown.

type Worker

type Worker interface {
	Task()
}

Worker must be implemented by types that want to use the work pool.

Directories

Path Synopsis
This sample program demonstrates how to use the work package to use a pool of goroutines to get work done.
This sample program demonstrates how to use the work package to use a pool of goroutines to get work done.

Jump to

Keyboard shortcuts

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