futures

package
v0.0.0-...-8eb2345 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2015 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package futures emulates Python's concurrent.futures package as well as is possible with Go's lack of parametric types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

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

Maintains the pool of workers and receives new work.

func NewExecutor

func NewExecutor(maxWorkers int) *Executor

Create a new Executor that does up to maxWorkers tasks in parallel.

func (*Executor) Map

func (me *Executor) Map(fn func(interface{}) interface{}, inputs <-chan interface{}) <-chan interface{}

Calls fn with each item received from inputs, and outputs the results in the same order to the returned channel.

func (*Executor) Shutdown

func (me *Executor) Shutdown()

Prevents new tasks being submitted, and cleans up workers when all futures have been processed.

func (*Executor) Submit

func (me *Executor) Submit(fn func() interface{}) *Future

Submit the function to the Executor, returning a Future that represents it.

type Future

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

Represents some asynchronous execution.

func (*Future) Result

func (me *Future) Result() interface{}

Blocks until the Future completes, and returns the computed value.

Jump to

Keyboard shortcuts

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