workQ

package module
v0.0.0-...-ad466b8 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2013 License: MIT Imports: 1 Imported by: 0

README

workQ

Documentation

Overview

a try at making FIFO container that runs and waits for method of it's Workers before it returns them, but doesn't block on writes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WorkQ

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

A queue of Workers that runs the Work() function on them async, but return them in FIFO order after Work() has finished

TODO: make it more natural to get things out look at the test for basic implementation of a typed wrapper

func NewWorkQ

func NewWorkQ() WorkQ

get a new WorkQ

func (*WorkQ) In

func (w *WorkQ) In() chan<- Worker

you write on this channel.

if you close it the WorkQ will close the Out() channel after there are no more workers and will become unusable

func (*WorkQ) Out

func (w *WorkQ) Out() <-chan Worker

you read from here.

if the In() channel is closed this channel will close after the last element in

type Worker

type Worker interface {
	// is the function that will be called and will be waited to finish before the worker can be returned
	Work()
}

the interface that needs to be implemented

Jump to

Keyboard shortcuts

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