2 ms·
I think the point is that you can omit atomics in async case, if you are always using async in single thread mode.
by sanxiyn 6y ago
I think the point is that you can omit atomics in async case, if you are always using async in single thread mode.
- thegeomaster 6y agoNot just atomics, you'd probably need mutexes or rwlocks in a lot of scenarios, and these can become a bottleneck quickly if you don't think it through. Async has the benefit of context switches (handing off execution) being explicit, so you're fine as long as you don't leave any half-updated state before you do an async function call.
- afavour 6y agoRust also lets you avoid atomics by using structs that implement Send. Having an async function return such a struct is a lot easier to map mentally (for me, at least)