58
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
this post was submitted on 05 Sep 2024
58 points (100.0% liked)
Rust
5926 readers
22 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
I think I would put the emphasis slightly differently: I don’t feel the confusion is around the word “spawn”, but it spawns futures rather than tasks. For tasks you might indeed expect them to be picked up in the background (which is what work-stealing does), but futures only execute when polled.
The most interesting part here is the polling only has to take place on the scope itself. That was actually what I wanted to check, but got distracted because all spawns are awaited in the scope in
moro
's README example.The non-awaited jobs are run concurrently as the moro docs say. But what if we immediately await f2?
f1 and f2 are run concurrently, f3 is run after f2 finishes, but doesn't have to wait for f1 to finish, which is maybe obvious, but... (see below).
So two things here:
defer_to_scope()
be confusing if the job is awaited in the scope?