Skip to content

Instantly share code, notes, and snippets.

@jsbattig
Created March 16, 2015 04:16
Show Gist options
  • Save jsbattig/88d7525f112eb587bc47 to your computer and use it in GitHub Desktop.
Save jsbattig/88d7525f112eb587bc47 to your computer and use it in GitHub Desktop.
Sample test that will break fiber utilization in Delphi
procedure TestTJobQueue.JobMethodRaiseAndSwitchToFiber(const AJob: IJob; const AParams: array of Variant);
begin
try
Check(True);
raise ETestJobQueue.Create('Hello');
except
on E : Exception do
begin
try
raise ETestJobQueue.Create('Hello Nested');
except
on E : Exception do
begin
try
raise ETestJobQueue.Create('Hello More Nested');
except
on E : Exception do
begin
AJob.Sleep(400); // <-- This call will perform a SwitchToFiber() to emulate a blocking wait
CheckEqualsString('Hello More Nested', E.Message);
end;
end;
CheckEqualsString('Hello Nested', E.Message);
end;
end;
CheckEqualsString('Hello', E.Message);
end;
end;
Check(True);
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment