Refactoring
This commit is contained in:
+15
-15
@@ -16,9 +16,9 @@ type
|
||||
// Helper class to notify a latch when its Notify method is called.
|
||||
TLatchNotifierSubscriber = class(TInterfacedObject, IMycSubscriber)
|
||||
private
|
||||
FGateLatch: IMycEvent;
|
||||
FGateLatch: IMycLatch;
|
||||
public
|
||||
constructor Create(AGateLatch: IMycEvent);
|
||||
constructor Create(AGateLatch: IMycLatch);
|
||||
// IMycSubscriber
|
||||
function Notify: Boolean; // Implements IMycSubscriber.Notify [cite: 46, 181, 299]
|
||||
end;
|
||||
@@ -54,7 +54,7 @@ implementation
|
||||
|
||||
{ TLatchNotifierSubscriber }
|
||||
|
||||
constructor TLatchNotifierSubscriber.Create(AGateLatch: IMycEvent);
|
||||
constructor TLatchNotifierSubscriber.Create(AGateLatch: IMycLatch);
|
||||
begin
|
||||
inherited Create;
|
||||
FGateLatch := AGateLatch;
|
||||
@@ -121,12 +121,12 @@ end;
|
||||
procedure TTestMycGateFuncFuture.Test_ChainedExecution_WithDelayedInitState;
|
||||
var
|
||||
LFuture: IMycFuture<string>;
|
||||
LInitLatch: IMycEvent;
|
||||
LInitLatch: IMycLatch;
|
||||
LResultValue: string;
|
||||
const
|
||||
CExpectedResult = 'ChainCompleted';
|
||||
begin
|
||||
LInitLatch := TEvent.CreateLatch(1); // Create an init state that is not yet set [cite: 77, 212, 330]
|
||||
LInitLatch := TLatch.CreateLatch(1); // Create an init state that is not yet set [cite: 77, 212, 330]
|
||||
|
||||
LFuture :=
|
||||
TMycGateFuncFuture<string>.Create(
|
||||
@@ -220,9 +220,9 @@ end;
|
||||
procedure TTestMycGateFuncFuture.Test_GetResult_BeforeDone_RaisesException;
|
||||
var
|
||||
LFuture: IMycFuture<Integer>;
|
||||
LInitLatch: IMycEvent;
|
||||
LInitLatch: IMycLatch;
|
||||
begin
|
||||
LInitLatch := TEvent.CreateLatch(1);
|
||||
LInitLatch := TLatch.CreateLatch(1);
|
||||
|
||||
LFuture :=
|
||||
TMycGateFuncFuture<Integer>.Create(
|
||||
@@ -250,17 +250,17 @@ procedure TTestMycGateFuncFuture.Test_FanIn_OneFutureWaitsForMultipleOthers;
|
||||
var
|
||||
LPrerequisiteFuture1, LPrerequisiteFuture2: IMycFuture<Integer>;
|
||||
LMainFuture: IMycFuture<string>;
|
||||
LGateLatch: IMycEvent;
|
||||
LGateLatch: IMycLatch;
|
||||
LSub1, LSub2: IMycSubscriber; // To hold the TLatchNotifierSubscriber instances
|
||||
LInitStateP1, LInitStateP2: IMycEvent;
|
||||
Subscriptions: array[1..2] of TState.TSubscription; // To manage subscriptions
|
||||
LInitStateP1, LInitStateP2: IMycLatch;
|
||||
Subscriptions: array[1..2] of TSubscription; // To manage subscriptions
|
||||
const
|
||||
CMainFutureResult = 'AllPrerequisitesCompleted';
|
||||
begin
|
||||
FProcExecutionCount := 0; // Reset for this test
|
||||
|
||||
// Gate Latch: MainFuture waits for this latch, which needs 2 notifications.
|
||||
LGateLatch := TEvent.CreateLatch(2); // [cite: 77, 212, 330]
|
||||
LGateLatch := TLatch.CreateLatch(2); // [cite: 77, 212, 330]
|
||||
|
||||
// Create MainFuture, AInitState is the GateLatch's state.
|
||||
LMainFuture :=
|
||||
@@ -276,7 +276,7 @@ begin
|
||||
|
||||
// Setup Prerequisite Futures
|
||||
// PrerequisiteFuture1
|
||||
LInitStateP1 := TEvent.CreateLatch(1); // Controllable init state for PF1
|
||||
LInitStateP1 := TLatch.CreateLatch(1); // Controllable init state for PF1
|
||||
LPrerequisiteFuture1 :=
|
||||
TMycGateFuncFuture<Integer>.Create(
|
||||
FTaskFactory,
|
||||
@@ -291,7 +291,7 @@ begin
|
||||
Subscriptions[1] := LPrerequisiteFuture1.Done.Subscribe(LSub1); // Subscribe to PF1's completion [cite: 56, 188, 306]
|
||||
|
||||
// PrerequisiteFuture2
|
||||
LInitStateP2 := TEvent.CreateLatch(1); // Controllable init state for PF2
|
||||
LInitStateP2 := TLatch.CreateLatch(1); // Controllable init state for PF2
|
||||
LPrerequisiteFuture2 :=
|
||||
TMycGateFuncFuture<Integer>.Create(
|
||||
FTaskFactory,
|
||||
@@ -335,7 +335,7 @@ end;
|
||||
|
||||
procedure TTestMycGateFuncFuture.Test_FanOut_MultipleFuturesWaitForOneTrigger;
|
||||
var
|
||||
LTriggerLatch: IMycEvent;
|
||||
LTriggerLatch: IMycLatch;
|
||||
LFutureA, LFutureB: IMycFuture<Integer>;
|
||||
LFlagFutureARan, LFlagFutureBRan: Boolean;
|
||||
begin
|
||||
@@ -343,7 +343,7 @@ begin
|
||||
LFlagFutureBRan := False;
|
||||
Self.FSharedCounter := 0; // Reset shared counter for this test
|
||||
|
||||
LTriggerLatch := TEvent.CreateLatch(1); // Single trigger [cite: 77, 212, 330]
|
||||
LTriggerLatch := TLatch.CreateLatch(1); // Single trigger [cite: 77, 212, 330]
|
||||
|
||||
// Future A
|
||||
LFutureA :=
|
||||
|
||||
Reference in New Issue
Block a user