-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
concurrency.ForEachJob()
#113
Commits on Jan 11, 2022
-
concurrency.ForEachJob() replaces .ForEach()
Previous `ForEach()` required transforming the input into a slice of interfaces (causing an allocation on heap for each job, although that's minor here), and type asserting each job in the function later (generics will save us, but they're still not here). Plus since job index is not known, most use cases require a mutex to concatenate the results. This replaces it with `ForEachJob` instead, which provides the index of the job to `jobFunc` instead, letting it decide how to handle it. In most cases that usage will be accessing the original jobs slice, with proper type checking. Given the index of the job is known, no mutex is needed to store the result in a slice afterwards (see test change), plus since indexes are just ints, we don't even need a channel. This fits all the `concurrency.ForEach` uses I could find, and since there's no released version of dskit yet, I just removed that function. Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Configuration menu - View commit details
-
Copy full SHA for 3f61fb4 - Browse repository at this point
Copy the full SHA 3f61fb4View commit details -
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Configuration menu - View commit details
-
Copy full SHA for 0f6aeb7 - Browse repository at this point
Copy the full SHA 0f6aeb7View commit details -
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Configuration menu - View commit details
-
Copy full SHA for 1d3748e - Browse repository at this point
Copy the full SHA 1d3748eView commit details -
Remove the low-value benchmark
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Configuration menu - View commit details
-
Copy full SHA for 5b0be33 - Browse repository at this point
Copy the full SHA 5b0be33View commit details -
Bring ForEach back, with proper deprecation notice
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Configuration menu - View commit details
-
Copy full SHA for 6faae52 - Browse repository at this point
Copy the full SHA 6faae52View commit details -
PR feedback on job order and ctx.Err check
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Configuration menu - View commit details
-
Copy full SHA for a491840 - Browse repository at this point
Copy the full SHA a491840View commit details
Commits on Jan 12, 2022
-
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com> Co-authored-by: Peter Štibraný <peter.stibrany@grafana.com>
Configuration menu - View commit details
-
Copy full SHA for 2934349 - Browse repository at this point
Copy the full SHA 2934349View commit details -
Don't define a variable for context.Background()
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Configuration menu - View commit details
-
Copy full SHA for a19cdad - Browse repository at this point
Copy the full SHA a19cdadView commit details -
Configuration menu - View commit details
-
Copy full SHA for 133a232 - Browse repository at this point
Copy the full SHA 133a232View commit details