Refactoring
This commit is contained in:
@@ -81,7 +81,7 @@ type
|
||||
procedure HandleException;
|
||||
procedure EnqueueJob(const Job: TProc);
|
||||
function Run(Job: TProc): IMycSubscriber;
|
||||
function CreateTask(const Gate: TState; const Proc: TProc): TState.TSubscription;
|
||||
function CreateTask(const Gate: TState; const Proc: TProc): TSubscription;
|
||||
procedure WaitFor(State: IMycState);
|
||||
procedure Teardown;
|
||||
function InMainThread: Boolean;
|
||||
@@ -188,7 +188,7 @@ begin
|
||||
Result.NameThreadForDebugging(DbgName); // Set thread name for debugging
|
||||
end;
|
||||
|
||||
function TMycTaskFactory.CreateTask(const Gate: TState; const Proc: TProc): TState.TSubscription;
|
||||
function TMycTaskFactory.CreateTask(const Gate: TState; const Proc: TProc): TSubscription;
|
||||
begin
|
||||
if Gate.IsSet then
|
||||
begin
|
||||
@@ -203,11 +203,11 @@ end;
|
||||
|
||||
function TMycTaskFactory.CreateThread(const Proc: TProc): IMycState;
|
||||
var
|
||||
res: IMycEvent;
|
||||
res: IMycLatch;
|
||||
capturedProc: TProc;
|
||||
begin
|
||||
// Create a latch that will be signaled when the proc finishes
|
||||
res := TEvent.CreateLatch(1);
|
||||
res := TLatch.CreateLatch(1);
|
||||
|
||||
capturedProc := Proc; // Capture Proc for the anonymous method
|
||||
CreateAnonymousThread(
|
||||
@@ -309,7 +309,7 @@ begin
|
||||
raise ETaskException.Create('Task factory terminated');
|
||||
|
||||
if not Assigned(Job) then
|
||||
exit(TEvent.Null); // Already correct, uses direct static property on TMycLatch
|
||||
exit(TLatch.Null); // Already correct, uses direct static property on TMycLatch
|
||||
|
||||
// Create a pending job
|
||||
Result := TMycPendingJob.Create(Self, Job);
|
||||
|
||||
Reference in New Issue
Block a user