util

package
v0.0.0-...-821bc58 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: Apache-2.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 WorkersPool

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

WorkersPool provides a simple synchronization between workers doing some work. First add jobs by using AddWork(), then add a worker function using `SetWorker`. Finally, start as many workers as you want using `Start`.

func (*WorkersPool) AddWork

func (w *WorkersPool) AddWork(job interface{})

func (*WorkersPool) SetWorker

func (w *WorkersPool) SetWorker(workerFunc func(int, interface{}))

SetWorker defines function that will be run by workers. workerFunc accepts two parameters:

  • first provides ID of the worker [0, workers-1],
  • seconds provides data that worker should work on.

func (*WorkersPool) Start

func (w *WorkersPool) Start(workers int)

Start starts worker to execute workerFunc

func (*WorkersPool) WorkSize

func (w *WorkersPool) WorkSize() int

Jump to

Keyboard shortcuts

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