Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not include unit WinAPI.Windows in MVCFramework.ObjectPool #682

Closed
wuhao13 opened this issue Aug 17, 2023 · 0 comments
Closed

Do not include unit WinAPI.Windows in MVCFramework.ObjectPool #682

wuhao13 opened this issue Aug 17, 2023 · 0 comments
Assignees
Labels
accepted Issue has been accepted and inserted in a future milestone
Milestone

Comments

@wuhao13
Copy link

wuhao13 commented Aug 17, 2023

Do not include unit WinAPI.Windows in MVCFramework.ObjectPool, ZeroMemory function can use FillChar instead

procedure TCleanupThread<T>.Execute;
var
  lTargetSize: Integer;
  lAvgSize: TPoolSizeSamples;
  lArrIndex: Integer;
  lSampleTick: Integer;
begin
  lArrIndex := 0;
  lSampleTick := 0;
  while not Terminated do
  begin
    Inc(lSampleTick);
    lArrIndex := lSampleTick mod AVG_SAMPLES_COUNT;
    lAvgSize[lArrIndex] := fObjectPool.Size;
    if (lAvgSize[lArrIndex] > 0) and (GetAveragePoolSize(lAvgSize) >= fObjectPool.fShrinkTriggerSize) then
    begin
      fObjectPool.Lock;
      try
        fObjectPool.ShrinkPoolTo(fObjectPool.fShrinkTargetSize);
        FillChar(lAvgSize, SizeOf(lAvgSize),0);
       // ZeroMemory(@lAvgSize, SizeOf(lAvgSize));
      finally
        fObjectPool.UnLock;
      end;
    end
    else
    begin
      Sleep(GObjectPoolSamplingIntervalMS);
      if lSampleTick = MaxInt  then
      begin
        lSampleTick := 0;
      end;
    end;
  end;
end;
@danieleteti danieleteti self-assigned this Aug 30, 2023
@danieleteti danieleteti added the accepted Issue has been accepted and inserted in a future milestone label Aug 30, 2023
@danieleteti danieleteti added this to the 3.4.0-neon milestone Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Issue has been accepted and inserted in a future milestone
Projects
None yet
Development

No branches or pull requests

2 participants