This commit is contained in:
Michael Schimmel
2025-06-06 01:34:44 +02:00
parent c4d8607d17
commit f70cfe0ec1
2 changed files with 6 additions and 36 deletions
+4 -27
View File
@@ -62,7 +62,7 @@ type
protected
function GetValue: T; virtual; abstract;
public
constructor Create(const AChanged: TState);
constructor Create(const AChanged: TSignal);
destructor Destroy; override;
function Pop(out Res: T): Boolean;
end;
@@ -73,16 +73,7 @@ type
protected
function GetValue: T; override;
public
constructor Create(const AChanged: TState; const AProc: TFunc<T>);
end;
TMycChainedLazy<T> = class(TMycLazyBase<T>)
private
FValue: TLazy<T>.ILazy;
protected
function GetValue: T; override;
public
constructor Create(const AValue: TLazy<T>.ILazy);
constructor Create(const AChanged: TSignal.ISignal; const AProc: TFunc<T>);
end;
implementation
@@ -159,7 +150,7 @@ end;
{ TMycLazyBase<T> }
constructor TMycLazyBase<T>.Create(const AChanged: TState);
constructor TMycLazyBase<T>.Create(const AChanged: TSignal);
begin
inherited Create;
FChanged := TFlag.CreateFlag;
@@ -189,7 +180,7 @@ end;
{ TMycFuncLazy<T> }
constructor TMycFuncLazy<T>.Create(const AChanged: TState; const AProc: TFunc<T>);
constructor TMycFuncLazy<T>.Create(const AChanged: TSignal.ISignal; const AProc: TFunc<T>);
begin
inherited Create(AChanged);
FProc := AProc;
@@ -201,20 +192,6 @@ begin
Result := FProc();
end;
{ TMycChainedLazy<T> }
constructor TMycChainedLazy<T>.Create(const AValue: TLazy<T>.ILazy);
begin
inherited Create(AValue.Changed);
FValue := AValue;
end;
function TMycChainedLazy<T>.GetValue: T;
begin
if not FValue.Pop(Result) then
raise Exception.Create('Lazy chain already popped');
end;
constructor TMycFuncMutable<T>.Create(const AChanged: TSignal; const AProc: TFunc<T>);
begin
inherited Create(AChanged);