workerpool

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: BSD-3-Clause Imports: 4 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
	Workers []*Worker
	// contains filtered or unexported fields
}

Pool воркера

func NewPool

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

NewPool инициализирует новый пул с заданными задачами и

func (*Pool) AddTask

func (p *Pool) AddTask(task *Task)

func (*Pool) Run

func (p *Pool) Run()

func (*Pool) RunBackground

func (p *Pool) RunBackground()

func (*Pool) Stop

func (p *Pool) Stop()

type Task

type Task struct {
	Err  error
	Data *url.URL
	// contains filtered or unexported fields
}

func NewTask

func NewTask(f func(interface{}) error, data *url.URL) *Task

type Worker

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

Worker контролирует всю работу

func NewWorker

func NewWorker(channel chan *Task, ID int) *Worker

NewWorker возвращает новый экземпляр worker-а

func (*Worker) Start

func (wr *Worker) Start(wg *sync.WaitGroup)

Start запуск worker

func (*Worker) StartBackground

func (wr *Worker) StartBackground()

func (*Worker) Stop

func (wr *Worker) Stop()

Jump to

Keyboard shortcuts

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