2 ms·
Within your sync callback spawned via spawn_blocking, you can run async code with Handle::current().block_on(…): https://docs.rs/tokio/latest/tokio/runtime/stru
by anderskaseorg 3y ago
Within your sync callback spawned via spawn_blocking, you can run async code with Handle::current().block_on(…): https://docs.rs/tokio/latest/tokio/runtime/struct.Handle.html#method.block_on https://docs.rs/tokio/latest/tokio/runtime/struct.Handle.htm....
- rklaehn 3y agoWhich panics if you don't call it in the right context. So now you have code which can only be used under certain circumstances and with one particular async runtime. Since when has it become acceptable in rust to have fns that just panic depending on the state of some thread local? That is one thing I really dislike about tokio. The thread local runtime is convenience over correctness, which is antithetical to what rust usually favours.