Skip to content

Preserve order when collecting results #11

@anuraaga

Description

@anuraaga

When using CollectWithErrs, I noticed that the results aren't returned in the order of invocations of .Go.

Items are added in order from the pipe

https://github.com/wandb/parallel/blob/main/collect.go#L188

And the pipe is sent to immediately when Go completes

https://github.com/wandb/parallel/blob/main/collect.go#L348

To have order, I can return an indexed struct and sort myself, but I was wondering if it would make sense to do this in the library? It seems to make the executor easier to use, especially when compared to e.g. errgroup. Otherwise, maybe the doc comment can include a note that results aren't ordered in any way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions