-
-
Notifications
You must be signed in to change notification settings - Fork 97
Async::Task#wait_all #89
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
Conversation
Waits on all children to complete, including subtasks. Returns the result of the toplevel task.
I'd like to see this feature added too. Useful. |
It's useful but it's also risky because some interfaces will create tasks for persistent connections that will outlive your own tasks and if you try to wait on them you will be waiting forever. We could try to introduced |
Coming back to this, I think it would help for |
I've been thinking about this (shower thoughts) and I don't know if this is helpful, but I've been thinking of bucket = Async::Barrier.new
barrier.async { some_expensive_work }
some_other_method
something_over_here
do_this_in_the_bucket_too(bucket)
def do_this_in_the_bucket_too(bucket) = bucket.async { this_too }
bucket.wait I'm still trying to wrap my head around all of this async and/or concurrency stuff (I'm also learning Swift and SwiftUI now) but I wonder if this kind of framing is helpful at all -- tl;dr calling I was also wondering if it would be useful to be able to "tag" async tasks and then Anyway, just some food for thought on this topic! I hope I'm not too far off base! :) |
@trevorturk that's pretty accurate.
@bryanp it's not arbitrary, it's because the risk of Suppose you have an We could mitigate this by only waiting on non-transient tasks, but this only covers some use cases. Although I'd be happier about it since transient tasks are designed explicitly around life-cycles that go beyond the current task, which effectively means they should be invisible to That being said, even if |
Thanks everyone for the discussion. For the reasons given above, I'm going to hold off on this PR for now. |
Provides a way to wait on all children, including children and their tasks. This came out of a conversation I had with @ioquatix last week and is the approach I ended up moving forward with for my own use-case.
Types of Changes
Testing