3 ms·
Well, you wouldn't go for Arc (atomic RC) unless you need to share data across tasks (threads), within the same task you can use Rc. This is different from sha
by eddyb 12y ago
Well, you wouldn't go for Arc (atomic RC) unless you need to share data across tasks (threads), within the same task you can use Rc.
This is different from shared_ptr in C++ which is always atomic and LLVM has to try hard (in clang, no idea what GCC does) to eliminate some redundant ref-counts.
Oh and since Rc is affine, you only ref-count when you call .clone() on it or you let it fall out of scope.
Most of the time you can pass a reference to the contents, or, if you need to sometimes clone it, a reference to the Rc handle, avoiding ref-counting costs.
- steveklabnik 12y agoThat's true, thanks.