12 ms·
How do you handle the reference counting pauses in Rust then; rely on them being deterministic? Or do you completely avoid the reference counting boxes?
by falcolas 10y ago
How do you handle the reference counting pauses in Rust then; rely on them being deterministic? Or do you completely avoid the reference counting boxes?
- kibwen 10y agoNot the OP, but in my experience it's fairly rare to encounter someone using the `Rc` type in Rust. It's nowhere near as prevalent as `shared_ptr` seems to be in C++, for example.
- pimeys 10y agoThere is also the `Arc` type, which is an atomic reference counter. You still need those, especially if you need to share stuff between multiple threads.
- Jweb_Guru 10y agoYou can often get away with using scoped threads.
- vvanders 10y agoYeah, a lot of that has to do with the borrow checker guiding you towards single-ownership designs with is a good thing(tm).
- pimeys 10y agoThis is a good article about different wrapper types in Rust http://manishearth.github.io/blog/2015/05/27/wrapper-types-in-rust-choosing-your-guarantees/ http://manishearth.github.io/blog/2015/05/27/wrapper-types-i...
- dikaiosune 10y agoHow does reference counting pause? There's no stop-the-world GC action, as the garbage collection is amortized over every object deallocating itself.
- cmrdporcupine 10y agoThat's not entirely true, if your decrement results in a cascading free of an entire tree of objects you will pay for the deallocation time for that entire tree -- decrement, free, decrement children, free, etc.. And unless your RC algorithm is more clever than most that's going to be stop-the-world.
- TheHydroImpulse 10y agoRc is scoped to a single thread, so it'll be, at worst, stop-the-thread.