dms: bitbucket.org/anacrolix/dms/futures Index | Files

package futures

import "bitbucket.org/anacrolix/dms/futures"

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

Index

Package Files

futures.go

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.

Package futures imports 2 packages (graph) and is imported by 1 packages. Updated 2014-04-12. Refresh now. Tools for package owners.