execpool

package
v0.0.0-...-76c1feb Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BacklogPool

type BacklogPool interface {
	ExecutionPool
	EnqueueBacklog(enqueueCtx context.Context, t ExecFunc, arg interface{}, out chan interface{}) error
}

BacklogPool supports all the ExecutionPool functions plus few more that tests the pending tasks.

func MakeBacklog

func MakeBacklog(execPool ExecutionPool, backlogSize int, priority Priority, owner interface{}) BacklogPool

MakeBacklog creates a backlog

type ExecFunc

type ExecFunc func(interface{}) interface{}

A ExecFunc is a unit of work to be executed by a Pool goroutine.

Note that a ExecFunc will occupy a Pool goroutine, so do not schedule tasks that spend an excessive amount of time waiting.

type ExecutionPool

type ExecutionPool interface {
	Enqueue(enqueueCtx context.Context, t ExecFunc, arg interface{}, i Priority, out chan interface{}) error
	GetOwner() interface{}
	Shutdown()
	GetParallelism() int
}

ExecutionPool interface exposes the core functionality of the execution pool.

func MakePool

func MakePool(owner interface{}) ExecutionPool

MakePool creates a pool.

type Priority

type Priority uint8

A Priority specifies a hint to the Pool to execute a Task at some priority.

Tasks with higher Priority values will tend to finish more quickly.

If there are tasks with different priorities, a worker will pick the highest-priority task to execute next.

const (
	LowPriority Priority = iota
	HighPriority
)

The list of all valid priority values. When adding new ones, add them before numPrios. (i.e. there should be no gaps, and the first priority needs to be zero)

Jump to

Keyboard shortcuts

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