TDataSeries<T>
This commit is contained in:
+83
-83
@@ -99,15 +99,15 @@ begin
|
||||
LInitStateAsState := TState.Null;
|
||||
|
||||
LFuture :=
|
||||
TMycGateFuncFuture<Integer>.Create(
|
||||
FTaskFactory,
|
||||
LInitStateAsState,
|
||||
function: Integer
|
||||
begin
|
||||
Inc(Self.FProcExecutionCount);
|
||||
Result := CExpectedResult;
|
||||
end
|
||||
);
|
||||
TMycGateFuncFuture<Integer>.Create(
|
||||
FTaskFactory,
|
||||
LInitStateAsState,
|
||||
function: Integer
|
||||
begin
|
||||
Inc(Self.FProcExecutionCount);
|
||||
Result := CExpectedResult;
|
||||
end
|
||||
);
|
||||
|
||||
FTaskFactory.WaitFor(LFuture.Done); // Accesses IMycFuture.GetDone [cite: 110, 234, 352]
|
||||
|
||||
@@ -129,15 +129,15 @@ begin
|
||||
LInitLatch := TLatch.Construct(1); // Create an init state that is not yet set [cite: 77, 212, 330]
|
||||
|
||||
LFuture :=
|
||||
TMycGateFuncFuture<string>.Create(
|
||||
FTaskFactory,
|
||||
LInitLatch.State,
|
||||
function: string
|
||||
begin
|
||||
Inc(Self.FProcExecutionCount);
|
||||
Result := CExpectedResult;
|
||||
end
|
||||
);
|
||||
TMycGateFuncFuture<string>.Create(
|
||||
FTaskFactory,
|
||||
LInitLatch.State,
|
||||
function: string
|
||||
begin
|
||||
Inc(Self.FProcExecutionCount);
|
||||
Result := CExpectedResult;
|
||||
end
|
||||
);
|
||||
|
||||
Assert.AreEqual(0, FProcExecutionCount, 'AProc should not have executed yet.');
|
||||
Assert.IsFalse(LFuture.Done.IsSet, 'Future should not be done yet.');
|
||||
@@ -168,15 +168,15 @@ begin
|
||||
LInitStateAsState := TState.Null; // Immediate execution
|
||||
|
||||
LFuture :=
|
||||
TMycGateFuncFuture<Integer>.Create(
|
||||
LLocalTaskFactory,
|
||||
LInitStateAsState,
|
||||
function: Integer
|
||||
begin
|
||||
Inc(Self.FProcExecutionCount);
|
||||
raise Exception.Create(CExceptionMessage);
|
||||
end
|
||||
);
|
||||
TMycGateFuncFuture<Integer>.Create(
|
||||
LLocalTaskFactory,
|
||||
LInitStateAsState,
|
||||
function: Integer
|
||||
begin
|
||||
Inc(Self.FProcExecutionCount);
|
||||
raise Exception.Create(CExceptionMessage);
|
||||
end
|
||||
);
|
||||
|
||||
try
|
||||
LLocalTaskFactory.WaitFor(LFuture.Done);
|
||||
@@ -225,15 +225,15 @@ begin
|
||||
LInitLatch := TLatch.Construct(1);
|
||||
|
||||
LFuture :=
|
||||
TMycGateFuncFuture<Integer>.Create(
|
||||
FTaskFactory,
|
||||
LInitLatch.State,
|
||||
function: Integer
|
||||
begin
|
||||
Inc(Self.FProcExecutionCount);
|
||||
Result := 123;
|
||||
end
|
||||
);
|
||||
TMycGateFuncFuture<Integer>.Create(
|
||||
FTaskFactory,
|
||||
LInitLatch.State,
|
||||
function: Integer
|
||||
begin
|
||||
Inc(Self.FProcExecutionCount);
|
||||
Result := 123;
|
||||
end
|
||||
);
|
||||
|
||||
Assert.IsFalse(LFuture.Done.IsSet, 'Future should not be marked as done initially.');
|
||||
|
||||
@@ -264,44 +264,44 @@ begin
|
||||
|
||||
// Create MainFuture, AInitState is the GateLatch's state.
|
||||
LMainFuture :=
|
||||
TMycGateFuncFuture<string>.Create(
|
||||
FTaskFactory,
|
||||
LGateLatch.State,
|
||||
function: string
|
||||
begin
|
||||
Inc(Self.FProcExecutionCount, 10); // Indicate MainFuture's proc ran
|
||||
Result := CMainFutureResult;
|
||||
end
|
||||
);
|
||||
TMycGateFuncFuture<string>.Create(
|
||||
FTaskFactory,
|
||||
LGateLatch.State,
|
||||
function: string
|
||||
begin
|
||||
Inc(Self.FProcExecutionCount, 10); // Indicate MainFuture's proc ran
|
||||
Result := CMainFutureResult;
|
||||
end
|
||||
);
|
||||
|
||||
// Setup Prerequisite Futures
|
||||
// PrerequisiteFuture1
|
||||
LInitStateP1 := TLatch.Construct(1); // Controllable init state for PF1
|
||||
LPrerequisiteFuture1 :=
|
||||
TMycGateFuncFuture<Integer>.Create(
|
||||
FTaskFactory,
|
||||
LInitStateP1.State,
|
||||
function: Integer
|
||||
begin
|
||||
Inc(Self.FProcExecutionCount, 1); // PF1 ran
|
||||
Result := 1;
|
||||
end
|
||||
);
|
||||
TMycGateFuncFuture<Integer>.Create(
|
||||
FTaskFactory,
|
||||
LInitStateP1.State,
|
||||
function: Integer
|
||||
begin
|
||||
Inc(Self.FProcExecutionCount, 1); // PF1 ran
|
||||
Result := 1;
|
||||
end
|
||||
);
|
||||
LSub1 := TLatchNotifierSubscriber.Create(LGateLatch);
|
||||
Subscriptions[1] := LPrerequisiteFuture1.Done.Subscribe(LSub1); // Subscribe to PF1's completion [cite: 56, 188, 306]
|
||||
|
||||
// PrerequisiteFuture2
|
||||
LInitStateP2 := TLatch.Construct(1); // Controllable init state for PF2
|
||||
LPrerequisiteFuture2 :=
|
||||
TMycGateFuncFuture<Integer>.Create(
|
||||
FTaskFactory,
|
||||
LInitStateP2.State,
|
||||
function: Integer
|
||||
begin
|
||||
Inc(Self.FProcExecutionCount, 1); // PF2 ran
|
||||
Result := 2;
|
||||
end
|
||||
);
|
||||
TMycGateFuncFuture<Integer>.Create(
|
||||
FTaskFactory,
|
||||
LInitStateP2.State,
|
||||
function: Integer
|
||||
begin
|
||||
Inc(Self.FProcExecutionCount, 1); // PF2 ran
|
||||
Result := 2;
|
||||
end
|
||||
);
|
||||
LSub2 := TLatchNotifierSubscriber.Create(LGateLatch);
|
||||
Subscriptions[2] := LPrerequisiteFuture2.Done.Subscribe(LSub2); // Subscribe to PF2's completion
|
||||
|
||||
@@ -347,29 +347,29 @@ begin
|
||||
|
||||
// Future A
|
||||
LFutureA :=
|
||||
TMycGateFuncFuture<Integer>.Create(
|
||||
FTaskFactory,
|
||||
LTriggerLatch.State,
|
||||
function: Integer
|
||||
begin
|
||||
LFlagFutureARan := True;
|
||||
System.SyncObjs.TInterlocked.Increment(Self.FSharedCounter); // Thread-safe increment
|
||||
Result := 100;
|
||||
end
|
||||
);
|
||||
TMycGateFuncFuture<Integer>.Create(
|
||||
FTaskFactory,
|
||||
LTriggerLatch.State,
|
||||
function: Integer
|
||||
begin
|
||||
LFlagFutureARan := True;
|
||||
System.SyncObjs.TInterlocked.Increment(Self.FSharedCounter); // Thread-safe increment
|
||||
Result := 100;
|
||||
end
|
||||
);
|
||||
|
||||
// Future B
|
||||
LFutureB :=
|
||||
TMycGateFuncFuture<Integer>.Create(
|
||||
FTaskFactory,
|
||||
LTriggerLatch.State,
|
||||
function: Integer
|
||||
begin
|
||||
LFlagFutureBRan := True;
|
||||
System.SyncObjs.TInterlocked.Increment(Self.FSharedCounter); // Thread-safe increment
|
||||
Result := 200;
|
||||
end
|
||||
);
|
||||
TMycGateFuncFuture<Integer>.Create(
|
||||
FTaskFactory,
|
||||
LTriggerLatch.State,
|
||||
function: Integer
|
||||
begin
|
||||
LFlagFutureBRan := True;
|
||||
System.SyncObjs.TInterlocked.Increment(Self.FSharedCounter); // Thread-safe increment
|
||||
Result := 200;
|
||||
end
|
||||
);
|
||||
|
||||
Assert.IsFalse(LFutureA.Done.IsSet, 'FutureA should not be done yet.');
|
||||
Assert.IsFalse(LFutureB.Done.IsSet, 'FutureB should not be done yet.');
|
||||
|
||||
Reference in New Issue
Block a user