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.
type Executor struct {
// contains filtered or unexported fields
}Maintains the pool of workers and receives new work.
func NewExecutor(maxWorkers int) *Executor
Create a new Executor that does up to maxWorkers tasks in parallel.
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 (me *Executor) Shutdown()
Prevents new tasks being submitted, and cleans up workers when all futures have been processed.
func (me *Executor) Submit(fn func() interface{}) *Future
Submit the function to the Executor, returning a Future that represents it.
type Future struct {
// contains filtered or unexported fields
}Represents some asynchronous execution.
func (me *Future) Result() interface{}
Blocks until the Future completes, and returns the computed value.