Refactoring

This commit is contained in:
Michael Schimmel
2025-06-05 23:46:09 +02:00
parent a57b2d50e4
commit 73d656cda5
2 changed files with 25 additions and 12 deletions
+15 -8
View File
@@ -22,20 +22,23 @@ type
property Done: TState read GetDone; property Done: TState read GetDone;
end; end;
private {$REGION 'private'}
FFuture: IFuture; strict private
function GetDone: TState.IState; inline;
function GetResult: T; inline;
class var class var
FNull: IFuture; FNull: IFuture;
class constructor CreateClass; class constructor CreateClass;
class destructor DestroyClass; class destructor DestroyClass;
private
FFuture: IFuture;
function GetDone: TState; inline;
function GetResult: T; inline;
{$ENDREGION}
public public
constructor Create(const AFuture: IFuture); constructor Create(const AFuture: IFuture);
class operator Initialize(out Dest: TFuture<T>);
class operator Implicit(const A: IFuture): TFuture<T>; overload; class operator Implicit(const A: IFuture): TFuture<T>; overload;
class operator Implicit(const A: TFuture<T>): IFuture; overload; class operator Implicit(const A: TFuture<T>): IFuture; overload;
@@ -45,10 +48,9 @@ type
class property Null: IFuture read FNull; class property Null: IFuture read FNull;
function Chain<S>(const Proc: TFunc<T, S>): TFuture<S>; function Chain<S>(const Proc: TFunc<T, S>): TFuture<S>;
function WaitFor: T; function WaitFor: T;
property Done: TState.IState read GetDone; property Done: TState read GetDone;
property Result: T read GetResult; property Result: T read GetResult;
end; end;
@@ -93,7 +95,7 @@ begin
Result := TMycGateFuncFuture<T>.Create(TaskManager, Gate, Proc); Result := TMycGateFuncFuture<T>.Create(TaskManager, Gate, Proc);
end; end;
function TFuture<T>.GetDone: TState.IState; function TFuture<T>.GetDone: TState;
begin begin
Result := FFuture.Done; Result := FFuture.Done;
end; end;
@@ -119,4 +121,9 @@ begin
Result := A.FFuture; Result := A.FFuture;
end; end;
class operator TFuture<T>.Initialize(out Dest: TFuture<T>);
begin
Dest.FFuture := FNull;
end;
end. end.
+10 -4
View File
@@ -30,6 +30,7 @@ type
procedure Unsubscribe; procedure Unsubscribe;
end; end;
{$REGION 'private'}
strict private strict private
class var class var
FNull: ISignal; FNull: ISignal;
@@ -37,7 +38,7 @@ type
private private
FSignal: ISignal; FSignal: ISignal;
{$ENDREGION}
public public
constructor Create(const ASignal: ISignal); constructor Create(const ASignal: ISignal);
class operator Initialize(out Dest: TSignal); class operator Initialize(out Dest: TSignal);
@@ -55,6 +56,7 @@ type
procedure Trigger; procedure Trigger;
end; end;
{$REGION 'private'}
strict private strict private
class var class var
FNull: IEvent; FNull: IEvent;
@@ -62,7 +64,7 @@ type
private private
FEvent: IEvent; FEvent: IEvent;
{$ENDREGION}
public public
constructor Create(const AEvent: IEvent); constructor Create(const AEvent: IEvent);
class operator Initialize(out Dest: TEvent); class operator Initialize(out Dest: TEvent);
@@ -85,6 +87,7 @@ type
property IsSet: Boolean read GetIsSet; property IsSet: Boolean read GetIsSet;
end; end;
{$REGION 'private'}
strict private strict private
class var class var
FNull: IState; FNull: IState;
@@ -93,7 +96,7 @@ type
private private
FState: IState; FState: IState;
function GetIsSet: Boolean; inline; function GetIsSet: Boolean; inline;
{$ENDREGION}
public public
constructor Create(const AState: IState); constructor Create(const AState: IState);
class operator Initialize(out Dest: TState); class operator Initialize(out Dest: TState);
@@ -120,6 +123,7 @@ type
property State: TState read GetState; property State: TState read GetState;
end; end;
{$REGION 'private'}
strict private strict private
class var class var
FNull: ILatch; FNull: ILatch;
@@ -128,7 +132,7 @@ type
private private
FLatch: ILatch; FLatch: ILatch;
function GetState: TState; inline; function GetState: TState; inline;
{$ENDREGION}
public public
constructor Create(const ALatch: ILatch); constructor Create(const ALatch: ILatch);
class operator Initialize(out Dest: TLatch); class operator Initialize(out Dest: TLatch);
@@ -155,6 +159,7 @@ type
property State: TState read GetState; property State: TState read GetState;
end; end;
{$REGION 'private'}
strict private strict private
class var class var
FNull: IFlag; FNull: IFlag;
@@ -164,6 +169,7 @@ type
FDirty: IFlag; FDirty: IFlag;
function GetState: TState; inline; function GetState: TState; inline;
{$ENDREGION}
public public
constructor Create(const ADirty: IFlag); constructor Create(const ADirty: IFlag);
class operator Initialize(out Dest: TFlag); class operator Initialize(out Dest: TFlag);