5 ms·
These collections are of somewhat limited use outside of concurrent scenarios, and I don't think you can (currently?) be generic over allocation in Rust. Since
by masklinn 9y ago
These collections are of somewhat limited use outside of concurrent scenarios, and I don't think you can (currently?) be generic over allocation in Rust. Since these structures need some sort of automatic memory management for structural sharing, you need to use a GC of some sort, having both atomic and non-atomic Rc would require duplicating the entire thing, once with Rc nodes and one with Arc node, for more or less no value.
> I may be misunderstanding the implications of Arc and how it is implemented, and how it behaves in the absence of multiple threads
All Arc means is that refcounting operations use atomic increment/decrement instead of regular ones.
- seeekr 9y agoSo that means that the synchronization cost would only be paid when making a new copy of the Arc and releasing each of those. Ok, that extends the set of use cases where it's acceptable to use Arc then. Thanks for clarifying. EDIT: wording
- masklinn 9y ago> So that means that the synchronization cost would only be paid when making a new copy of the Arc and releasing each of those. Yes. An interesting note here is that due to Rust's ubiquitous use of references there will be little extraneous refcounting traffic unlike systems like e.g. Python where `a = b` might trigger a refcount increase. I think it was Armin Ronacher (mitsuhiko) who made that observation a few weeks back, possibly on twitter?