sem

package
v0.0.0-...-1327151 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package sem provides safe concurrent access to a bounded pool of resources.

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 concurrent access to a fixed bounded pool of resources

func NewPool

func NewPool(items ...interface{}) *Pool

NewPool builds a pool providing concurrent access to the given items.

func (*Pool) Acquire

func (p *Pool) Acquire(ctx context.Context, n int) ([]interface{}, error)

Acquire n items from the pool. Blocks until the requested items are available or the context is cancelled.

func (*Pool) Release

func (p *Pool) Release(items []interface{})

Release returns items to the pool.

Jump to

Keyboard shortcuts

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