Documentation ¶
Index ¶
- type Task
- type TaskResult
- type TaskResultCh
- type TaskResultSet
- func (trs *TaskResultSet) Channels() []TaskResultCh
- func (trs *TaskResultSet) FirstError() error
- func (trs *TaskResultSet) FirstValue() interface{}
- func (trs *TaskResultSet) LatestResult(index int) (TaskResult, bool)
- func (trs *TaskResultSet) Reap() *TaskResultSet
- func (trs *TaskResultSet) Wait() *TaskResultSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Task ¶
val: the value returned after task execution. err: the error returned during task completion. abort: tells Parallel to return, whether or not all tasks have completed.
type TaskResult ¶
type TaskResult struct { Value interface{} Error error }
type TaskResultCh ¶
type TaskResultCh <-chan TaskResult
type TaskResultSet ¶
type TaskResultSet struct {
// contains filtered or unexported fields
}
func Parallel ¶
func Parallel(tasks ...Task) (trs *TaskResultSet, ok bool)
Run tasks in parallel, with ability to abort early. Returns ok=false iff any of the tasks returned abort=true. NOTE: Do not implement quit features here. Instead, provide convenient concurrent quit-like primitives, passed implicitly via Task closures. (e.g. it's not Parallel's concern how you quit/abort your tasks).
func (*TaskResultSet) Channels ¶
func (trs *TaskResultSet) Channels() []TaskResultCh
func (*TaskResultSet) FirstError ¶
func (trs *TaskResultSet) FirstError() error
Returns the firstmost (by task index) error as discovered by all previous Reap() calls.
func (*TaskResultSet) FirstValue ¶
func (trs *TaskResultSet) FirstValue() interface{}
Returns the firstmost (by task index) error as discovered by all previous Reap() calls.
func (*TaskResultSet) LatestResult ¶
func (trs *TaskResultSet) LatestResult(index int) (TaskResult, bool)
func (*TaskResultSet) Reap ¶
func (trs *TaskResultSet) Reap() *TaskResultSet
NOTE: Not concurrency safe. Writes results to trs.results without waiting for all tasks to complete.
func (*TaskResultSet) Wait ¶
func (trs *TaskResultSet) Wait() *TaskResultSet
NOTE: Not concurrency safe. Like Reap() but waits until all tasks have returned or panic'd.