Moved signal interfaces inside records

This commit is contained in:
Michael Schimmel
2025-06-05 23:27:48 +02:00
parent 7ba42b0c7c
commit a57b2d50e4
15 changed files with 316 additions and 313 deletions
+8 -8
View File
@@ -21,7 +21,7 @@ type
// Returns IMycState to await thread completion.
// Exceptions within Proc are caught; the first one is stored
// and can be re-raised in the main thread via WaitFor or Teardown.
function CreateThread(const Proc: TProc): IMycState;
function CreateThread(const Proc: TProc): TState.IState;
// Returns True if called from the main application thread.
function InMainThread: Boolean;
@@ -77,12 +77,12 @@ type
constructor Create;
destructor Destroy; override;
class function CreateAnonymousThread(const DbgName: String; const Proc: TProc): TThread;
function CreateThread(const Proc: TProc): IMycState;
function CreateThread(const Proc: TProc): TState.IState;
procedure HandleException;
procedure EnqueueJob(const Job: TProc);
function Run(Job: TProc): IMycSubscriber;
function CreateTask(const Gate: TState; const Proc: TProc): TSubscription;
procedure WaitFor(State: IMycState);
function CreateTask(const Gate: TState; const Proc: TProc): TSignal.TSubscription;
procedure WaitFor(State: TState.IState);
procedure Teardown;
function InMainThread: Boolean;
function InWorkerThread: Boolean;
@@ -188,7 +188,7 @@ begin
Result.NameThreadForDebugging(DbgName); // Set thread name for debugging
end;
function TMycTaskFactory.CreateTask(const Gate: TState; const Proc: TProc): TSubscription;
function TMycTaskFactory.CreateTask(const Gate: TState; const Proc: TProc): TSignal.TSubscription;
begin
if Gate.IsSet then
begin
@@ -201,9 +201,9 @@ begin
end;
end;
function TMycTaskFactory.CreateThread(const Proc: TProc): IMycState;
function TMycTaskFactory.CreateThread(const Proc: TProc): TState.IState;
var
res: IMycLatch;
res: TLatch.ILatch;
capturedProc: TProc;
begin
// Create a latch that will be signaled when the proc finishes
@@ -345,7 +345,7 @@ begin
end;
end;
procedure TMycTaskFactory.WaitFor(State: IMycState);
procedure TMycTaskFactory.WaitFor(State: TState.IState);
var
lock: TSemaphore; // This is System.SyncObjs.TSemaphore
begin