when_all method
Is your feature request related to a problem? Please describe.
No problems, just inspiration from the implemented when_any with coroutines.
Describe the solution you'd like
Stated above, it would be nice to have a when_all (analogous to a Promise.allSettled from JS) method that works very similarly to when_any, except on the return condition. So all coroutines in the proposed when_all call would have to be fulfilled before resuming execution. In other words, it would resume when all coroutines complete.
Describe alternatives you've considered
Instead of alternatives, I'll give a use case. Say you want to send a DM to multiple users and want to wait until all of them have responded/interacted/etc. with the message. You could use this when_all to do this very easily.
Additional context
This may already be a feature idk, but if not, it would be a logical pairing with when_any.
Thanks for the suggestion! I've been putting this off mostly because it's very easy to do it without a dedicated library feature:
dpp::task<void> tasks[4];
for (auto& task : tasks) {
task = bot.co_do_something();
}
for (auto& task : tasks) {
co_await task;
}
Though maybe a when_all could do something this can't, I'm not sure. It could also just exist and do that, I just haven't had much time lately so it's been low priority.
Thanks for the suggestion! I've been putting this off mostly because it's very easy to do it without a dedicated library feature:
dpp::task<void> tasks[4]; for (auto& task : tasks) { task = bot.co_do_something(); } for (auto& task : tasks) { co_await task; }Though maybe a
when_allcould do something this can't, I'm not sure. It could also just exist and do that, I just haven't had much time lately so it's been low priority.
Tbh I would take a when_all as a "fire in any order and be await them all to complete", but I guess you could just let them fire in order.
I do wonder if there's any specific case to needing it to be randomly fired.
Could jobs be launched in parallel perhaps? I'm not sure if when_any is implemented like this, or if this is feasible. Would be something interesting to explore if it's possible though.
Could jobs be launched in parallel perhaps? I'm not sure if
when_anyis implemented like this, or if this is feasible. Would be something interesting to explore if it's possible though.
This happens to begin with with dpp::task and dpp::async
This issue has had no activity and is being marked as stale. If you still wish to continue with this issue please comment to reopen it.
Bump
This issue has had no activity and is being marked as stale. If you still wish to continue with this issue please comment to reopen it.