Skip to content

Commit b7731bc

Browse files
committed
atomic incr/decr-compare
1 parent 413de31 commit b7731bc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

source/adapters/native_cpu/common.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,16 @@ struct _ur_object {
6161
ur_shared_mutex Mutex;
6262
};
6363

64+
// Todo: replace this with a common helper once it is available
6465
struct RefCounted {
6566
std::atomic_uint32_t _refCount;
66-
void incrementReferenceCount() { _refCount++; }
67-
void decrementReferenceCount() { _refCount--; }
67+
uint32_t incrementReferenceCount() { return ++_refCount; }
68+
uint32_t decrementReferenceCount() { return --_refCount; }
6869
RefCounted() : _refCount{1} {}
6970
uint32_t getReferenceCount() const { return _refCount; }
7071
};
7172

7273
template <typename T> inline void decrementOrDelete(T *refC) {
73-
refC->decrementReferenceCount();
74-
if (refC->getReferenceCount() == 0)
74+
if (refC->decrementReferenceCount() == 0)
7575
delete refC;
7676
}

0 commit comments

Comments
 (0)