task

package
v0.0.0-...-bcfd2cf Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Task

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

Task provides a pool of goroutines that can execute any Worker tasks that are submitted.

func New

func New(maxGoroutines int) *Task

New creates a new work pool. instanced with singleton pattern beacuse used centrally as worker pool based on CPU resources

func (*Task) Do

func (t *Task) Do(w Worker)

Do submits work to the pool.

func (*Task) Shutdown

func (t *Task) Shutdown()

Shutdown waits for all the goroutines to shutdown.

func (*Task) Wait

func (t *Task) Wait()

Wait waits for all the goroutines to complete.

type Worker

type Worker interface {
	Work()
}

Worker must be implemented by types that want to use the run pool.

Jump to

Keyboard shortcuts

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