taskqueue

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2018 License: MPL-2.0 Imports: 2 Imported by: 6

Documentation

Overview

Package taskqueue provides a queue for executing tasks asynchronously.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger func(v ...interface{})

Logger provides a way to log panics caused by workers in a queue.

type Option

type Option func(*Queue)

Option defines an option for the queue.

func Depth

func Depth(depth int) Option

Depth sets the depth of the queue. Calls to Submit() will block when this number of tasks are already pending execution. Pass in a negative number to use an unbounded queue. Defaults to unbounded.

func Log

func Log(logger Logger) Option

Log sets the logger for tasks that panic. Defaults to no logger.

func Workers

func Workers(workers int) Option

Workers sets the number of workers that will simultaneously process tasks. If this is set to 1, tasks submitted to the queue will be executed serially. Defaults to one plus the number of CPUs.

type Queue

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

Queue holds the queue information.

func New

func New(options ...Option) *Queue

New creates a queue which executes the tasks submitted to it.

func (*Queue) Shutdown

func (q *Queue) Shutdown()

Shutdown the queue. Does not return until all pending tasks have completed.

func (*Queue) Submit

func (q *Queue) Submit(task Task)

Submit a task to be run.

type Task

type Task func()

Task defines a unit of work.

Jump to

Keyboard shortcuts

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