From 3d5c1b4ef878143437042a94a2c306cf60cee214 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Mon, 29 Feb 2016 19:16:37 +0100 Subject: [PATCH] Core|Common: restore old interlocked add/sub behavior interlocked* returns the new value whereas fetch_add/sub returns the old value. --- common/src/Utilities/Mutex.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/Utilities/Mutex.cpp b/common/src/Utilities/Mutex.cpp index 9822b3bb21..246387f805 100644 --- a/common/src/Utilities/Mutex.cpp +++ b/common/src/Utilities/Mutex.cpp @@ -120,7 +120,7 @@ Threading::Mutex::~Mutex() throw() Threading::MutexRecursive::MutexRecursive() : Mutex( false ) { - if( _attr_refcount.fetch_add(1) == 1 ) + if( ++_attr_refcount == 1 ) { if( 0 != pthread_mutexattr_init( &_attr_recursive ) ) throw Exception::OutOfMemory(L"Recursive mutexing attributes"); @@ -134,7 +134,7 @@ Threading::MutexRecursive::MutexRecursive() : Mutex( false ) Threading::MutexRecursive::~MutexRecursive() throw() { - if( _attr_refcount.fetch_sub(1) == 0 ) + if( --_attr_refcount == 0 ) pthread_mutexattr_destroy( &_attr_recursive ); }