We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b292148 commit 815fe83Copy full SHA for 815fe83
Quick.Pooling.pas
@@ -295,22 +295,22 @@ function TPoolItem<T>._AddRef: Integer;
295
296
function TPoolItem<T>._Release: Integer;
297
begin
298
- fLock.Enter;
299
{$IFDEF DEBUG_OBJPOOL}
300
TDebugger.Trace(Self,'Released Pool item');
301
{$ENDIF}
302
try
303
- Dec(fRefCount);
304
- Result := fRefCount;
+ result:=AtomicDecrement(fRefCount);
305
if Result = 0 then
306
307
FreeAndNil(fItem);
+ // The following is take from TInterfacedObject._Release()
+ // Mark the refcount field so that any refcounting during destruction doesn't infinitely recurse.
308
+ __MarkDestroying(Self);
309
Destroy;
310
end
311
else fLastAccess := Now;
312
finally
313
if fRefCount = 1 then fSemaphore.Release;
- fLock.Leave;
314
end;
315
316
0 commit comments