Core: new blenlib library for implicit-sharing #105994
|
@ -73,7 +73,7 @@ class ImplicitSharingInfo : NonCopyable, NonMovable {
|
|||
*/
|
||||
void remove_user_and_delete_if_last() const
|
||||
{
|
||||
const int old_user_count = users_.fetch_sub(1, std::memory_order_relaxed);
|
||||
const int old_user_count = users_.fetch_sub(1, std::memory_order_acq_rel);
|
||||
brecht marked this conversation as resolved
Outdated
|
||||
BLI_assert(old_user_count >= 1);
|
||||
const bool was_last_user = old_user_count == 1;
|
||||
if (was_last_user) {
|
||||
|
|
Loading…
Reference in New Issue
My understanding is that user count decrement requires
std::memory_order_acq_rel
, while increment can usestd::memory_order_relaxed
.For example libc++ does this for shared_ptr. More details:
https://stackoverflow.com/questions/48124031/stdmemory-order-relaxed-atomicity-with-respect-to-the-same-atomic-variable