Earlier quoted context omitted.
I think the JS world might be particularly excited about async/await because other people just escape to threads when they don't want to block the whole thing on IO. Both in JS or Rust, you don't gain anything just by declaring your thing to be async, or awaitable. Your function needs to be built around some kind of "primitive" that explicitly supports the "do something else in the meantime" mechanism. Using "await"…
The latest tokio has a work-stealing threadpools, so you don’t need to explicitly do this anymore, IIRC.
Inside Rust's Async Transform
81–84 of 84 posts
Re: Inside Rust's Async Transform
#82Earlier quoted context omitted.
The latest tokio has a work-stealing threadpools, so you don’t need to explicitly do this anymore, IIRC.
Neat! Do you know if there's anything in there resembling the rayon::join API? I didn't see anything on a cursory look.
Re: Inside Rust's Async Transform
#83Async/await pattern always confuses me, someone please let me know if I get this right: First, async/await does NOT mean "threading" or "multiprocessing" or "concurrency". It simply means "using a state machine to alternate between tasks, which may or may not be concurrent." Right? Further, in Javascript, futures and async are utilized heavily because we so frequently need to wait for IO events (i.e.: network events)…
I think the JS world might be particularly excited about async/await because other people just escape to threads when they don't want to block the whole thing on IO. Both in JS or Rust, you don't gain anything just by declaring your thing to be async, or awaitable. Your function needs to be built around some kind of "primitive" that explicitly supports the "do something else in the meantime" mechanism. Using "await"…
I'm not familiar with Rust but in JS you do gain something. Just the fact that the function is async means that it now explicitly returns a promise, which means that anything awaiting that promise will be in a new execution context and will definitely not run synchronously.
Re: Inside Rust's Async Transform
#84Earlier quoted context omitted.
One difference that may exist is that in Rust, async fns don’t immediately execute, they simply create one of these values. I forget if JS and C# do something different, that is, the execute up until the first suspend point. This was one of the major design decisions we’ve made that’s different than other languages.
JS starts immediately but even if the function's return value is "ready" synchronously, you can't get its value back synchronously.