File tree Expand file tree Collapse file tree 2 files changed +410
-266
lines changed
samples/delphi/QuickPooling Expand file tree Collapse file tree 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;
295295
296296function TPoolItem <T>._Release: Integer;
297297begin
298- fLock.Enter;
299298 { $IFDEF DEBUG_OBJPOOL}
300299 TDebugger.Trace(Self,' Released Pool item' );
301300 { $ENDIF}
302301 try
303- Dec(fRefCount);
304- Result := fRefCount;
302+ result:=AtomicDecrement(fRefCount);
305303 if Result = 0 then
306304 begin
307305 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);
308309 Destroy;
309310 end
310311 else fLastAccess := Now;
311312 finally
312313 if fRefCount = 1 then fSemaphore.Release;
313- fLock.Leave;
314314 end ;
315315end ;
316316
You can’t perform that action at this time.
0 commit comments