Skip to content

Commit b433efe

Browse files
authored
Merge pull request #9581 from kjbracey-arm/sharedptr_atomic
SharedPtr: use atomic load
2 parents b4e09cf + 52aac4c commit b433efe

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

platform/SharedPtr.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,7 @@ class SharedPtr {
177177
uint32_t use_count() const
178178
{
179179
if (_ptr != NULL) {
180-
core_util_critical_section_enter();
181-
uint32_t current_counter = *_counter;
182-
core_util_critical_section_exit();
183-
return current_counter;
180+
return core_util_atomic_load_u32(_counter);
184181
} else {
185182
return 0;
186183
}
@@ -230,8 +227,7 @@ class SharedPtr {
230227
void decrement_counter()
231228
{
232229
if (_ptr != NULL) {
233-
uint32_t new_value = core_util_atomic_decr_u32(_counter, 1);
234-
if (new_value == 0) {
230+
if (core_util_atomic_decr_u32(_counter, 1) == 0) {
235231
delete _counter;
236232
_counter = NULL;
237233
delete _ptr;

0 commit comments

Comments
 (0)