parallelwork

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package parallelwork implements pallel work queue with fixed number of workers that concurrently process and add work items to the queue.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallbackFunc

type CallbackFunc func() error

CallbackFunc is a callback function.

func OnNthCompletion added in v0.7.3

func OnNthCompletion(n int, callback CallbackFunc) CallbackFunc

OnNthCompletion invokes the provided callback once the returned callback function has been invoked exactly n times.

type Queue

type Queue struct {
	ProgressCallback func(ctx context.Context, enqueued, active, completed int64)
	// contains filtered or unexported fields
}

Queue represents a work queue with multiple parallel workers.

func NewQueue

func NewQueue() *Queue

NewQueue returns new parallel work queue.

func (*Queue) EnqueueBack

func (v *Queue) EnqueueBack(ctx context.Context, callback CallbackFunc)

EnqueueBack adds the work to the back of the queue.

func (*Queue) EnqueueFront

func (v *Queue) EnqueueFront(ctx context.Context, callback CallbackFunc)

EnqueueFront adds the work to the front of the queue.

func (*Queue) Process

func (v *Queue) Process(ctx context.Context, workers int) error

Process starts N workers, which will be processing elements in the queue until the queue is empty and all workers are idle or until any of the workers returns an error.

Jump to

Keyboard shortcuts

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