worker

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2018 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool struct {
	Tasks []*Task
	// contains filtered or unexported fields
}

Pool is the base model for tasks work group

func NewPool

func NewPool(tasks []*Task, concurrency int) *Pool

NewPool creates a worker pool given tasks and concurrency

func (*Pool) Run

func (p *Pool) Run()

Run runs all work within the pool and blocks until it's finished.

type Task

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

Task is the generic task model

func NewTask

func NewTask(f func() error) *Task

NewTask initializes a new task based on a given work function.

func (*Task) Run

func (t *Task) Run(wg *sync.WaitGroup)

Run runs a task and marks wait group as done

Jump to

Keyboard shortcuts

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