Skip to content

Commit 5fd02b0

Browse files
committed
Remove decrementAndTestReferenceCount
1 parent dfd6090 commit 5fd02b0

File tree

2 files changed

+1
-17
lines changed

2 files changed

+1
-17
lines changed

source/adapters/cuda/command_buffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ urCommandBufferRetainExp(ur_exp_command_buffer_handle_t hCommandBuffer) {
130130

131131
UR_APIEXPORT ur_result_t UR_APICALL
132132
urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t hCommandBuffer) {
133-
if (!hCommandBuffer->decrementAndTestReferenceCount())
133+
if (hCommandBuffer->decrementReferenceCount() != 0)
134134
return UR_RESULT_SUCCESS;
135135

136136
delete hCommandBuffer;

source/adapters/cuda/command_buffer.hpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -222,20 +222,4 @@ struct ur_exp_command_buffer_handle_t_ {
222222
// Used when releasing an object.
223223
uint32_t decrementReferenceCount() noexcept { return --RefCount; }
224224
uint32_t getReferenceCount() const noexcept { return RefCount; }
225-
// This method allows to guard a code which needs to be executed when object's
226-
// ref count becomes zero after release. It is important to notice that only a
227-
// single thread can pass through this check. This is true because of several
228-
// reasons:
229-
// 1. Decrement operation is executed atomically.
230-
// 2. It is not allowed to retain an object after its refcount reaches zero.
231-
// 3. It is not allowed to release an object more times than the value of
232-
// the ref count.
233-
// 2. and 3. basically means that we can't use an object at all as soon as its
234-
// refcount reaches zero. Using this check guarantees that code for deleting
235-
// an object and releasing its resources is executed once by a single thread
236-
// and we don't need to use any mutexes to guard access to this object in the
237-
// scope after this check. Of course if we access another objects in this code
238-
// (not the one which is being deleted) then access to these objects must be
239-
// guarded, for example with a mutex.
240-
bool decrementAndTestReferenceCount() { return --RefCount == 0; }
241225
};

0 commit comments

Comments
 (0)