pool

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2020 License: Apache-2.0 Imports: 3 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

Overview

Package pool contains a simple threadpool implementation that accepts work in the form of `func() error` function. The intent is for it to support similar workloads to errgroup, but with a maximum number of concurrent worker threads.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// Go queues a single unit of work for execution on this pool. All calls
	// to Go must be finished before Wait is called.
	Go(func() error)

	// Wait blocks until all work is complete, returning the first
	// error returned by any of the work.
	Wait() error
}

Interface defines an errgroup-compatible interface for interacting with our threadpool.

func New

func New(workers int) Interface

New creates a fresh worker pool with the specified size.

func NewWithCapacity

func NewWithCapacity(workers, capacity int) Interface

NewWithCapacity creates a fresh worker pool with the specified size.

func NewWithContext added in v0.12.0

func NewWithContext(ctx context.Context, workers, capacity int) (Interface, context.Context)

NewWithContext creates a pool that is driven by a cancelable context. Just like errgroup.Group on first error the context will be canceled as well.

Jump to

Keyboard shortcuts

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