10 ms·
I'm guessing it was downvoted for mentioning Rust ¯\_(ツ)_/¯ For sure - it's a little terse, just to demonstrate the various cases async fn do_something_asyn
by mcronce 3y ago
I'm guessing it was downvoted for mentioning Rust ¯\_(ツ)_/¯
For sure - it's a little terse, just to demonstrate the various cases
async fn do_something_async() {
nonblocking_sync_call();
tokio::task::spawn_blocking(blocking_sync_call()).await;
async_std::task::spawn_blocking(blocking_sync_call()).await;
async_call().await;
}
fn do_something_sync() {
nonblocking_sync_call();
blocking_sync_call();
futures::executor::block_on(async_call());
}
There is _a bit_ of ceremony required to bridge the two, but it's pretty minimal.
If you want to know more about any of that, happy to explain or provide links for further reading