Merge pull request #9581 from kjbracey-arm/sharedptr_atomic

SharedPtr: use atomic load
pull/9602/head
Martin Kojtal 2019-02-04 14:39:54 +01:00 committed by GitHub
commit b433efecfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 6 deletions

View File

@ -177,10 +177,7 @@ public:
uint32_t use_count() const
{
if (_ptr != NULL) {
core_util_critical_section_enter();
uint32_t current_counter = *_counter;
core_util_critical_section_exit();
return current_counter;
return core_util_atomic_load_u32(_counter);
} else {
return 0;
}
@ -230,8 +227,7 @@ private:
void decrement_counter()
{
if (_ptr != NULL) {
uint32_t new_value = core_util_atomic_decr_u32(_counter, 1);
if (new_value == 0) {
if (core_util_atomic_decr_u32(_counter, 1) == 0) {
delete _counter;
_counter = NULL;
delete _ptr;