RefCounted.release method is not atomic.
void release() {
/*
...
*/
dec;
if(_impl._count == 0) {
/*
...
*/
}
}
calling "dec" is atomic and "_impl._count == 0" is atomic but together they are not atomic.
Something like this is necessary:
if(atomicFetchSub!(MemoryOrder.acq_rel)(_impl._count , 1) == 1){ //... }
Clang use it too:
https://github.com/llvm-mirror/libcxx/blob/master/include/memory#L3398
RefCounted.release method is not atomic.
calling "dec" is atomic and "_impl._count == 0" is atomic but together they are not atomic.
Something like this is necessary:
if(atomicFetchSub!(MemoryOrder.acq_rel)(_impl._count , 1) == 1){ //... }Clang use it too:
https://github.com/llvm-mirror/libcxx/blob/master/include/memory#L3398