work

package
v0.0.0-...-c429a28 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*options)

func NumWorker

func NumWorker(numWorker int) Option

num of workers

func WorkProxy

func WorkProxy(workProxy func(ctx context.Context, handler WorkHandler)) Option

work proxy

type TaskFunc

type TaskFunc func(ctx context.Context)

type WorkHandler

type WorkHandler func(ctx context.Context)

type Worker

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

func NewWorker

func NewWorker(f func()) *Worker

func (*Worker) Done

func (w *Worker) Done() <-chan struct{}

type WorkerPool

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

func NewWorkerPool

func NewWorkerPool(size int, o ...Option) *WorkerPool

func (*WorkerPool) Close

func (pool *WorkerPool) Close()

func (*WorkerPool) Run

func (pool *WorkerPool) Run(task TaskFunc)

func (*WorkerPool) RunContext

func (pool *WorkerPool) RunContext(ctx context.Context, task TaskFunc) error

func (*WorkerPool) TryRun

func (pool *WorkerPool) TryRun(task TaskFunc) bool

Jump to

Keyboard shortcuts

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