queue

package module
v0.0.0-...-9aab6b7 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2013 License: MIT Imports: 2 Imported by: 0

README

queue

Run tasks on seperate goroutines with control
Basic Example
import "github.com/otium/queue"

q := queue.NewQueue(func(val interface{}) {


}, 20)
for i := 0; i < 200; i++ {
    q.Push(i)
}
q.Wait()

Documentation: http://godoc.org/github.com/otium/queue

Documentation

Overview

Package queue provides a queue for running tasks concurrently up to a certain limit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(interface{})

Handler is a function that takes any value, and is called every time a task is processed from the queue

type Queue

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

Queue is the queue Queue also has the members Handler and ConcurrencyLimit which can be set at anytime

func NewQueue

func NewQueue(handler Handler, concurrencyLimit int) *Queue

NewQueue must be called to initialize a new queue. The first argument is a Handler The second argument is an int which specifies how many operation can run in parallel in the queue, zero means unlimited.

func (*Queue) Len

func (q *Queue) Len() (_, _ int)

Count returns the number of currently executing tasks and the number of tasks waiting to be executed

func (*Queue) Push

func (q *Queue) Push(val interface{})

Push pushes a new value to the end of the queue

func (*Queue) Stop

func (q *Queue) Stop()

Stop stops the queue from executing anymore tasks, and waits for the currently executing tasks to finish. The queue can not be started again once this is called

func (*Queue) Wait

func (q *Queue) Wait()

Wait calls wait on a waitgroup, that waits for all items of the queue to finish execution

Jump to

Keyboard shortcuts

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