File tree 2 files changed +410
-266
lines changed
samples/delphi/QuickPooling
2 files changed +410
-266
lines changed Original file line number Diff line number Diff line change @@ -295,22 +295,22 @@ function TPoolItem<T>._AddRef: Integer;
295
295
296
296
function TPoolItem <T>._Release: Integer;
297
297
begin
298
- fLock.Enter;
299
298
{ $IFDEF DEBUG_OBJPOOL}
300
299
TDebugger.Trace(Self,' Released Pool item' );
301
300
{ $ENDIF}
302
301
try
303
- Dec(fRefCount);
304
- Result := fRefCount;
302
+ result:=AtomicDecrement(fRefCount);
305
303
if Result = 0 then
306
304
begin
307
305
FreeAndNil(fItem);
306
+ // The following is take from TInterfacedObject._Release()
307
+ // Mark the refcount field so that any refcounting during destruction doesn't infinitely recurse.
308
+ __MarkDestroying(Self);
308
309
Destroy;
309
310
end
310
311
else fLastAccess := Now;
311
312
finally
312
313
if fRefCount = 1 then fSemaphore.Release;
313
- fLock.Leave;
314
314
end ;
315
315
end ;
316
316
You can’t perform that action at this time.
0 commit comments