File tree Expand file tree Collapse file tree 2 files changed +1
-17
lines changed Expand file tree Collapse file tree 2 files changed +1
-17
lines changed Original file line number Diff line number Diff line change @@ -130,7 +130,7 @@ urCommandBufferRetainExp(ur_exp_command_buffer_handle_t hCommandBuffer) {
130
130
131
131
UR_APIEXPORT ur_result_t UR_APICALL
132
132
urCommandBufferReleaseExp (ur_exp_command_buffer_handle_t hCommandBuffer) {
133
- if (! hCommandBuffer->decrementAndTestReferenceCount () )
133
+ if (hCommandBuffer->decrementReferenceCount () != 0 )
134
134
return UR_RESULT_SUCCESS;
135
135
136
136
delete hCommandBuffer;
Original file line number Diff line number Diff line change @@ -222,20 +222,4 @@ struct ur_exp_command_buffer_handle_t_ {
222
222
// Used when releasing an object.
223
223
uint32_t decrementReferenceCount () noexcept { return --RefCount; }
224
224
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 ; }
241
225
};
You can’t perform that action at this time.
0 commit comments