Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parallel ¶
func Parallel(main func(ParallelScope) error) error
Parallel executes a function in parallel scope. Compared to Run, it does not allow for early cancellation, therefore is suitable for non-blocking computations. Returns the first error returned by any of the spawned tasks. Waits until all the tasks complete, before returning.
func Run ¶
Run runs a scope capable of spawning tasks. It is guaranteed that all the spawned tasks will be executed (even if spawned after the context is cancelled), and that `Run` will return only after all the tasks have completed. Context of the tasks will be automatically cancelled as soon as ANY task returns an error. Returns the first error returned by any task (main or background).
Types ¶
type JoinHandle ¶
type JoinHandle[R any] struct { // contains filtered or unexported fields }
JoinHandle is a handle to an awaitable task.
type ParallelScope ¶
type ParallelScope struct {
// contains filtered or unexported fields
}
ParallelScope is a scope which doesn't require cancellation token, just parallelization.
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope of concurrenct tasks.
func (Scope) Spawn ¶
Spawn spawns a main task. Scope gets automatically canceled when all the main tasks return.
func (Scope) SpawnBg ¶
SpawnBg spawns a background task. Background tasks get canceled when all the main tasks return.
func (Scope) SpawnBgNamed ¶
SpawnBgNamed spawns a named background task.
func (Scope) SpawnNamed ¶
SpawnNamed spawns a named main task.