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
+21 -21
View File
@@ -16,9 +16,9 @@ type
// Helper class to notify a latch when its Notify method is called.
TLatchNotifierSubscriber = class(TInterfacedObject, IMycSubscriber)
private
FGateLatch: IMycLatch;
FGateLatch: TLatch.ILatch;
public
constructor Create(AGateLatch: IMycLatch);
constructor Create(AGateLatch: TLatch.ILatch);
// IMycSubscriber
function Notify: Boolean; // Implements IMycSubscriber.Notify [cite: 46, 181, 299]
end;
@@ -54,7 +54,7 @@ implementation
{ TLatchNotifierSubscriber }
constructor TLatchNotifierSubscriber.Create(AGateLatch: IMycLatch);
constructor TLatchNotifierSubscriber.Create(AGateLatch: TLatch.ILatch);
begin
inherited Create;
FGateLatch := AGateLatch;
@@ -89,8 +89,8 @@ end;
procedure TTestMycGateFuncFuture.Test_BasicSuccess_WithImmediateInitState;
var
LFuture: IMycFuture<Integer>;
LInitStateAsState: IMycState; // Parameter for Create
LFuture: TFuture<Integer>.IFuture;
LInitStateAsState: TState.IState; // Parameter for Create
LResultValue: Integer;
const
CExpectedResult = 42;
@@ -109,19 +109,19 @@ begin
end
);
FTaskFactory.WaitFor(LFuture.Done); // Accesses IMycFuture.GetDone [cite: 110, 234, 352]
FTaskFactory.WaitFor(LFuture.Done); // Accesses IFuture.GetDone [cite: 110, 234, 352]
Assert.IsTrue(LFuture.Done.IsSet, 'Future should be marked as done.'); // Accesses IMycState.IsSet [cite: 57, 194, 312]
Assert.IsTrue(LFuture.Done.IsSet, 'Future should be marked as done.'); // Accesses TState.IState.IsSet [cite: 57, 194, 312]
Assert.AreEqual(1, FProcExecutionCount, 'AProc should have been executed once.');
LResultValue := LFuture.GetResult; // Accesses IMycFuture.GetResult
LResultValue := LFuture.GetResult; // Accesses IFuture.GetResult
Assert.AreEqual(CExpectedResult, LResultValue, 'GetResult returned an unexpected value.');
end;
procedure TTestMycGateFuncFuture.Test_ChainedExecution_WithDelayedInitState;
var
LFuture: IMycFuture<string>;
LInitLatch: IMycLatch;
LFuture: tFuture<string>.IFuture;
LInitLatch: TLatch.ILatch;
LResultValue: string;
const
CExpectedResult = 'ChainCompleted';
@@ -155,9 +155,9 @@ end;
procedure TTestMycGateFuncFuture.Test_ExceptionInProc_HandledAsPlanned;
var
LFuture: IMycFuture<Integer>;
LFuture: TFuture<Integer>.IFuture;
LLocalTaskFactory: IMycTaskFactory;
LInitStateAsState: IMycState;
LInitStateAsState: TState.IState;
LResultValue: Integer;
LExpectedExceptionRaisedByFactory: Boolean;
const
@@ -219,8 +219,8 @@ end;
procedure TTestMycGateFuncFuture.Test_GetResult_BeforeDone_RaisesException;
var
LFuture: IMycFuture<Integer>;
LInitLatch: IMycLatch;
LFuture: TFuture<Integer>.IFuture;
LInitLatch: TLatch.ILatch;
begin
LInitLatch := TLatch.CreateLatch(1);
@@ -248,12 +248,12 @@ end;
procedure TTestMycGateFuncFuture.Test_FanIn_OneFutureWaitsForMultipleOthers;
var
LPrerequisiteFuture1, LPrerequisiteFuture2: IMycFuture<Integer>;
LMainFuture: IMycFuture<string>;
LGateLatch: IMycLatch;
LPrerequisiteFuture1, LPrerequisiteFuture2: TFuture<Integer>.IFuture;
LMainFuture: TFuture<string>.IFuture;
LGateLatch: TLatch.ILatch;
LSub1, LSub2: IMycSubscriber; // To hold the TLatchNotifierSubscriber instances
LInitStateP1, LInitStateP2: IMycLatch;
Subscriptions: array[1..2] of TSubscription; // To manage subscriptions
LInitStateP1, LInitStateP2: TLatch.ILatch;
Subscriptions: array[1..2] of TSignal.TSubscription; // To manage subscriptions
const
CMainFutureResult = 'AllPrerequisitesCompleted';
begin
@@ -335,8 +335,8 @@ end;
procedure TTestMycGateFuncFuture.Test_FanOut_MultipleFuturesWaitForOneTrigger;
var
LTriggerLatch: IMycLatch;
LFutureA, LFutureB: IMycFuture<Integer>;
LTriggerLatch: TLatch.ILatch;
LFutureA, LFutureB: TFuture<Integer>.IFuture;
LFlagFutureARan, LFlagFutureBRan: Boolean;
begin
LFlagFutureARan := False;