Created
May 3, 2021 19:26
-
-
Save glommer/33c2d0c3c50bd44eb2ab050fb142b4f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async fn some_async_function() { | |
let shared = Rc::new(Cell::new(0)); | |
let s = shared.clone(); | |
let x = Task::local(async move { | |
do_async_work(s).await; // used a Clone of shared state | |
}); // <== task starts executing here | |
do_more_work(shared); // <== may be still background executing here | |
x.await; // <== but is surely done here. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment