conc

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrentQueue

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

ConcurrentQueue is a pool of goroutines processing a stream of jobs. Job callbacks are called in the order they are added.

func NewConcurrentQueue

func NewConcurrentQueue(maxConcurrency int, initialElems ...func()) *ConcurrentQueue

NewConcurrentQueue constructs a new stream concurrency manager. initialElems contains the initial set of queued entries. if maxConcurrency <= 0, spawns infinite goroutines.

func (*ConcurrentQueue) Enqueue

func (s *ConcurrentQueue) Enqueue(jobs ...func())

Enqueue enqueues a job callback to the stream. Returns the current number of queued jobs. Note: may return 0 if the job was started immediately & the queue is empty.

func (*ConcurrentQueue) WaitIdle

func (s *ConcurrentQueue) WaitIdle(ctx context.Context, errCh <-chan error) error

WaitIdle waits for no jobs to be running. Returns context.Canceled if ctx is canceled. errCh is an optional error channel.

Jump to

Keyboard shortcuts

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