Documentation ¶
Index ¶
- func Map(size, numWorker int, f func(i int) error) error
- func MapWithContext(ctx context.Context, size, numWorker int, ...) error
- func MapWithCtxTimeout(baseCtx context.Context, size, numWorker int, timeout time.Duration, ...) error
- func MapWithTimeout(size, numWorker int, timeout time.Duration, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Map ¶ added in v1.0.2
Map is a helper function to parallel operate on slice. Example usage: ```
itemIDs := []int{1, 2, 3} items := make([]*Item, len(itemIDs)) routine.Map(len(items), 10, func(i int) { items[i] = getItemByID(itemIDs[i]) })
```
func MapWithContext ¶ added in v1.0.2
func MapWithCtxTimeout ¶
func MapWithTimeout ¶ added in v1.0.2
func MapWithTimeout(size, numWorker int, timeout time.Duration, f func(ctx context.Context, i int) error) error
MapWithTimeout is the same as Map, except each function need to be executed within timeout. Important reminder to handle the context provided: It is better to check the `ctx.Err() == nil` before any write operation, because the function may be canceled at any momement, and the underlying resource refering may have already been discarded.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.