Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Interface ¶
type Interface[T any] interface { // ParallelDo executes task within given routine in parallel. // // Note, this method is thread unsafe. ParallelDo(ctx context.Context, routine, task int) (T, error) // ParallelCollect handles execution result in a separate goroutine. // // Note, this method is thread safe. ParallelCollect(ctx context.Context, result *Result[T]) error }
Interface defines methods to support parallel execution.
type Result ¶
type Result[T any] struct { Routine int // routine index Task int // task index Value T // task execution result Err error // optional task execution error }
Result represents a task execution result.
type SerialOption ¶
type SerialOption struct { // Routines indicates the number of goroutines for parallel execution. // // By default, runtime.GOMAXPROCS(0) is used. Routines int // Window limits the maximum number of cached task execution result to handle in sequence. // // By default, 0 indicates no limit to execute all tasks as fast as it can. // // Otherwise, please set a proper value for some considerations, e.g. // - Limits the memory usage to cache task execution results. // - Business logic required. Window int }
func (*SerialOption) Normalize ¶
func (opt *SerialOption) Normalize(tasks int)
Click to show internal directories.
Click to hide internal directories.