Code formatting
This commit is contained in:
+11
-11
@@ -8,21 +8,21 @@ uses
|
||||
Myc.Lazy;
|
||||
|
||||
type
|
||||
TMycLazy<T> = class abstract( TInterfacedObject, IMycLazy<T> )
|
||||
TMycLazy<T> = class abstract(TInterfacedObject, IMycLazy<T>)
|
||||
protected
|
||||
function GetChanged: IMycState; virtual; abstract;
|
||||
public
|
||||
function Pop( out Res: T ): Boolean; virtual; abstract;
|
||||
function Pop(out Res: T): Boolean; virtual; abstract;
|
||||
end;
|
||||
|
||||
TMycNullLazy<T> = class( TMycLazy<T> )
|
||||
TMycNullLazy<T> = class(TMycLazy<T>)
|
||||
protected
|
||||
function GetChanged: IMycState; override;
|
||||
public
|
||||
function Pop( out Res: T ): Boolean; override;
|
||||
function Pop(out Res: T): Boolean; override;
|
||||
end;
|
||||
|
||||
TMycFuncLazy<T> = class( TMycLazy<T> )
|
||||
TMycFuncLazy<T> = class(TMycLazy<T>)
|
||||
private
|
||||
FChanged: IMycDirty;
|
||||
FChangeState: TState.TSubscription;
|
||||
@@ -32,7 +32,7 @@ type
|
||||
public
|
||||
constructor Create(const AChanged: TState; const AProc: TFunc<T>);
|
||||
destructor Destroy; override;
|
||||
function Pop( out Res: T ): Boolean; override;
|
||||
function Pop(out Res: T): Boolean; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@@ -44,9 +44,9 @@ begin
|
||||
Result := TState.Null;
|
||||
end;
|
||||
|
||||
function TMycNullLazy<T>.Pop( out Res: T ): Boolean;
|
||||
function TMycNullLazy<T>.Pop(out Res: T): Boolean;
|
||||
begin
|
||||
Res := Default ( T );
|
||||
Res := Default(T);
|
||||
Result := true;
|
||||
end;
|
||||
|
||||
@@ -57,7 +57,7 @@ begin
|
||||
inherited Create;
|
||||
FChanged := TDirty.Construct;
|
||||
FProc := AProc;
|
||||
FChangeState := AChanged.Subscribe( FChanged );
|
||||
FChangeState := AChanged.Subscribe(FChanged);
|
||||
end;
|
||||
|
||||
destructor TMycFuncLazy<T>.Destroy;
|
||||
@@ -71,12 +71,12 @@ begin
|
||||
Result := FChanged.State;
|
||||
end;
|
||||
|
||||
function TMycFuncLazy<T>.Pop( out Res: T ): Boolean;
|
||||
function TMycFuncLazy<T>.Pop(out Res: T): Boolean;
|
||||
begin
|
||||
Result := FChanged.State.IsSet;
|
||||
if Result then
|
||||
begin
|
||||
if Assigned( FProc ) then
|
||||
if Assigned(FProc) then
|
||||
Res := FProc;
|
||||
FChanged.Reset;
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user