TFuture<T>.Result --> TFuture<T>.Value

This commit is contained in:
Michael Schimmel
2025-06-06 12:50:59 +02:00
parent 98de7176c3
commit e7f381bc46
5 changed files with 40 additions and 40 deletions
+5 -5
View File
@@ -11,13 +11,13 @@ uses
type
TMycFuture<T> = class abstract(TInterfacedObject, TFuture<T>.IFuture)
protected
function GetResult: T; virtual; abstract;
function GetValue: T; virtual; abstract;
function GetDone: TState; virtual; abstract;
end;
TMycNullFuture<T> = class(TMycFuture<T>)
protected
function GetResult: T; override;
function GetValue: T; override;
function GetDone: TState; override;
end;
@@ -27,7 +27,7 @@ type
FDone: TLatch.ILatch;
FResult: T;
protected
function GetResult: T; override;
function GetValue: T; override;
function GetDone: TState; override;
public
constructor Create(const ATaskManager: IMycTaskManager; const AGate: TState.IState; AProc: TFunc<T>);
@@ -43,7 +43,7 @@ begin
Result := TState.Null;
end;
function TMycNullFuture<T>.GetResult: T;
function TMycNullFuture<T>.GetValue: T;
begin
Result := Default(T);
end;
@@ -90,7 +90,7 @@ begin
Result := FDone.State;
end;
function TMycGateFuncFuture<T>.GetResult: T;
function TMycGateFuncFuture<T>.GetValue: T;
begin
Assert(FDone.State.IsSet, 'Result is not yet available.');
Result := FResult;
+10 -10
View File
@@ -8,16 +8,16 @@ uses
Myc.TaskManager;
type
// Represents the eventual result of an asynchronous operation.
// Represents the eventual Value of an asynchronous operation.
TFuture<T> = record
type
IFuture = interface
{$REGION 'property access'}
function GetResult: T;
function GetValue: T;
function GetDone: TState;
{$ENDREGION}
// Provides access to the computed result.
property Result: T read GetResult;
// Provides access to the computed Value.
property Value: T read GetValue;
// Provides access to the completion state.
property Done: TState read GetDone;
end;
@@ -33,7 +33,7 @@ type
private
FFuture: IFuture;
function GetDone: TState; inline;
function GetResult: T; inline;
function GetValue: T; inline;
{$ENDREGION}
public
constructor Create(const AFuture: IFuture);
@@ -51,7 +51,7 @@ type
function WaitFor: T;
property Done: TState read GetDone;
property Result: T read GetResult;
property Value: T read GetValue;
end;
implementation
@@ -81,7 +81,7 @@ end;
function TFuture<T>.Chain<S>(const Proc: TFunc<T, S>): TFuture<S>;
begin
var Cap := FFuture;
Result := TFuture<S>.Construct(FFuture.Done, function: S begin Result := Proc(Cap.Result); end);
Result := TFuture<S>.Construct(FFuture.Done, function: S begin Result := Proc(Cap.Value); end);
end;
class function TFuture<T>.Construct(const Proc: TFunc<T>): TFuture<T>;
@@ -99,15 +99,15 @@ begin
Result := FFuture.Done;
end;
function TFuture<T>.GetResult: T;
function TFuture<T>.GetValue: T;
begin
Result := FFuture.Result;
Result := FFuture.Value;
end;
function TFuture<T>.WaitFor: T;
begin
TaskManager.WaitFor(FFuture.Done);
Result := FFuture.Result;
Result := FFuture.Value;
end;
class operator TFuture<T>.Implicit(const A: IFuture): TFuture<T>;
+4 -4
View File
@@ -462,19 +462,19 @@ begin // Start of LoadDataSeries
begin
var tickList := TList<TDataPoint>.Create;
try
var totalTicks := Length(liveData.Result);
var totalTicks := Length(liveData.Value);
var overallLastTabTickTime := 0.0;
for var P in loadedFiles do
Inc(totalTicks, Length(P.Result));
Inc(totalTicks, Length(P.Value));
tickList.Capacity := totalTicks;
for var P in loadedFiles do
begin
if Length(P.Result) > 0 then
if Length(P.Value) > 0 then
begin
for var iterTickData in P.Result do
for var iterTickData in P.Value do
if iterTickData.OADateTime > overallLastTabTickTime then
begin
tickList.Add(iterTickData);