This commit is contained in:
Michael Schimmel
2025-06-06 01:22:25 +02:00
parent 73d656cda5
commit c4d8607d17
13 changed files with 393 additions and 173 deletions
+5 -5
View File
@@ -36,7 +36,7 @@ type
// Exceptions during Job execution are caught; the first one is stored
// and can be re-raised in the main thread via WaitFor or Teardown.
// Raises ETaskException if the factory is already terminated.
function Run(Job: TProc): IMycSubscriber;
function Run(Job: TProc): TSignal.ISubscriber;
procedure EnqueueJob(const Job: TProc);
@@ -80,7 +80,7 @@ type
function CreateThread(const Proc: TProc): TState.IState;
procedure HandleException;
procedure EnqueueJob(const Job: TProc);
function Run(Job: TProc): IMycSubscriber;
function Run(Job: TProc): TSignal.ISubscriber;
function CreateTask(const Gate: TState; const Proc: TProc): TSignal.TSubscription;
procedure WaitFor(State: TState.IState);
procedure Teardown;
@@ -98,7 +98,7 @@ type
implementation
type
TMycPendingJob = class(TInterfacedObject, IMycSubscriber)
TMycPendingJob = class(TInterfacedObject, TSignal.ISubscriber)
private
[volatile]
FJob: TProc; // The job to execute when count reaches zero
@@ -112,7 +112,7 @@ type
property Owner: TMycTaskFactory read FOwner;
end;
TMycTaskWait = class sealed(TInterfacedObject, IMycSubscriber)
TMycTaskWait = class sealed(TInterfacedObject, TSignal.ISubscriber)
private
[volatile]
FSemaphore: TSemaphore; // System.SyncObjs.TSemaphore to be released on notification
@@ -303,7 +303,7 @@ begin
TaskManager := nil;
end;
function TMycTaskFactory.Run(Job: TProc): IMycSubscriber;
function TMycTaskFactory.Run(Job: TProc): TSignal.ISubscriber;
begin
if FTerminated <> 0 then
raise ETaskException.Create('Task factory terminated');