4 ms·
Well, you have to make sure that you use atomic reference counting in this case. Using regular reference counting will lead to subtle and hard-to-diagnose bugs.
by ootachi 15y ago
Well, you have to make sure that you use atomic reference counting in this case. Using regular reference counting will lead to subtle and hard-to-diagnose bugs.
Also, to answer your query, Rust uses unique pointers (the equivalent of std::unique_ptr in C++0x) for inter-thread communication. When the unique pointer goes out of scope, its memory is immediately freed (since it was the only owner of the data). And since the data has only one owner, it's data-race-free.
- angersock 15y agoYeah, one of the first things we fixed in our smart pointer implementation was to use atomic ops for the ref counters. This had the unfortunate side effect of excluding the smart pointer classes from our STL replacement (as it introduces a dependency on our low-level ops library), but in projects using both all is well. Cool on Rust, though! Thanks for the info!