worker

package
Version: v0.0.0-...-fc12ac8 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2016 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	FreeWorkers  chan *Worker
	Tasks        chan interface{}
	Done         chan bool
	TimeProcess  chan int64
	LastProcess  int64
	TotalTimeOut int64
}

manager model

func NewManager

func NewManager(numWorkers int) Manager

initiate new manager

func (*Manager) AssignTask

func (m *Manager) AssignTask(task interface{}, wg *sync.WaitGroup)

assign task to free worker

func (*Manager) DoMonitor

func (m *Manager) DoMonitor(wg *sync.WaitGroup)

do monitoring worker thats free or not

func (*Manager) EndWorker

func (m *Manager) EndWorker()

func (*Manager) InProgress

func (m *Manager) InProgress(result int64, wg *sync.WaitGroup)

check if a task still in progress to wait it till finish

func (*Manager) Timeout

func (m *Manager) Timeout(seconds int, wg *sync.WaitGroup)

set the timeout to waiting for tasks execution

type Worker

type Worker struct {
	WorkerId    int
	TimeProcess chan int64
	FreeWorkers chan *Worker
	Context     *Hive
}

worker model

func NewWorker

func NewWorker(id int, timeProcess <-chan int64, freeWorkers <-chan *Worker, ctx *Hive) Worker

func (*Worker) Work

func (w *Worker) Work(task interface{}, wg *sync.WaitGroup)

do a task for worker

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL