workerpool

package
v0.0.0-...-5dd4785 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2020 License: Apache-2.0, BSD-2-Clause Imports: 3 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEFAULT_OPTIONS = &Options{
	WorkerCount:          2 * runtime.NumCPU(),
	QueueSize:            4 * runtime.NumCPU(),
	FlushTasksAtShutdown: false,
}

Functions

This section is empty.

Types

type Option

type Option func(*Options)

func FlushTasksAtShutdown

func FlushTasksAtShutdown(flush bool) Option

func QueueSize

func QueueSize(queueSize int) Option

func WorkerCount

func WorkerCount(workerCount int) Option

type Options

type Options struct {
	WorkerCount          int
	QueueSize            int
	FlushTasksAtShutdown bool
}

func (Options) Override

func (options Options) Override(optionalOptions ...Option) *Options

type Task

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

func (*Task) Param

func (task *Task) Param(index int) interface{}

func (*Task) Return

func (task *Task) Return(result interface{})

type WorkerPool

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

func New

func New(workerFnc func(Task), optionalOptions ...Option) (result *WorkerPool)

func (*WorkerPool) GetPendingQueueSize

func (wp *WorkerPool) GetPendingQueueSize() int

func (*WorkerPool) GetWorkerCount

func (wp *WorkerPool) GetWorkerCount() int

func (*WorkerPool) Run

func (wp *WorkerPool) Run()

func (*WorkerPool) Start

func (wp *WorkerPool) Start()

func (*WorkerPool) Stop

func (wp *WorkerPool) Stop()

func (*WorkerPool) StopAndWait

func (wp *WorkerPool) StopAndWait()

func (*WorkerPool) Submit

func (wp *WorkerPool) Submit(params ...interface{}) (result chan interface{}, added bool)

func (*WorkerPool) TrySubmit

func (wp *WorkerPool) TrySubmit(params ...interface{}) (result chan interface{}, added bool)

Jump to

Keyboard shortcuts

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