I understand why structures that may block the current thread, like Mutex
and RwLock
, need to be reimplemented to rely on the futures/waker API, but why does it need to do so for Arc
?
As far as I understand, no operations on the standard Arc
are blocking, and in the latest version, async_std::sync::Arc
is just a reexport of std::sync::Arc
.
Is this future-proofing, in case a future implementation of Arc
needs to rely on blocking?
Which one should I use in async code, and why?
The point is to ease the transition from std
to async_std
as much as possible.
The description of the crates starts with:
This crate provides an async version of
std
.
And one of its descriptive feature is:
Intuitive: Complete parity with the stdlib means you only need to learn APIs once.
As for the blog post that introduced it, it clearly mentions that async_std
is mean to be a drop-in replacement of std
as much as possible:
With
async-std
, all that’s needed is replacestd
withasync_std
, add the prelude, and sprinkle in a few.awaits
(emphasis is mine)
Given all that, it makes sense that the developers of async_std
would chose to re-export all types from std
that don't need to be adapted to async
: Users don't need to worry about whether types are async
or not and don't need to worry about what to use
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With