parallelwork

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 License: Apache-2.0 Imports: 5 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

type Queue

type Queue struct {
	ProgressCallback func(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(callback CallbackFunc)

EnqueueBack adds the work to the back of the queue.

func (*Queue) EnqueueFront

func (v *Queue) EnqueueFront(callback CallbackFunc)

EnqueueFront adds the work to the front of the queue.

func (*Queue) Process

func (v *Queue) Process(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