hivemind

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package hivemind implements a simple worker pool, basically a `sync.Waitgroup` with fancy terminal output. Jobs added to a hive mind are executed by workers until `Wait` is called.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hivemind

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

A Hivemind wraps a worker pool

func New

func New(workers int) *Hivemind

New creates a new Hivemind. The `workers` variable sets the number of workers to instantiate. If <= 0, `workers` defaults to the number of CPU's present.

func (*Hivemind) AddJob

func (h *Hivemind) AddJob(j Job)

AddJob adds a job to the queue. If they weren't active already, spin up the workers.

func (*Hivemind) SetOutput

func (h *Hivemind) SetOutput(w io.Writer)

SetOutput sets the output destination for the hive.

func (*Hivemind) Wait

func (h *Hivemind) Wait()

Wait waits for all jobs to finish, and shuts down the hive.

type JC

type JC interface {
	SetTitle(string)
	Println(string)
	Printf(string, ...interface{})
}

JC for 'Job Control'

type Job

type Job interface {
	Run(j JC) error
}

A Job represents anything that can be performed in the Hivemind

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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