Implemented TLazy + Tests
This commit is contained in:
+10
-3
@@ -20,16 +20,20 @@ type
|
||||
end;
|
||||
|
||||
TFuture<T> = record
|
||||
strict private
|
||||
private
|
||||
FFuture: IMycFuture<T>;
|
||||
function GetDone: IMycState; inline;
|
||||
function GetResult: T; inline;
|
||||
|
||||
class var
|
||||
FNull: IMycFuture<T>;
|
||||
|
||||
class constructor CreateClass;
|
||||
class destructor DestroyClass;
|
||||
|
||||
public
|
||||
constructor Create(const AFuture: IMycFuture<T>);
|
||||
|
||||
class operator Implicit(const A: IMycFuture<T>): TFuture<T>; overload;
|
||||
class operator Implicit(const A: TFuture<T>): IMycFuture<T>; overload;
|
||||
|
||||
@@ -52,11 +56,14 @@ uses
|
||||
constructor TFuture<T>.Create(const AFuture: IMycFuture<T>);
|
||||
begin
|
||||
FFuture := AFuture;
|
||||
if not Assigned(FFuture) then
|
||||
FFuture := FNull;
|
||||
end;
|
||||
|
||||
class constructor TFuture<T>.CreateClass;
|
||||
begin
|
||||
TMycTaskFactory.AquireTaskManager;
|
||||
FNull := TMycNullFuture<T>.Create;
|
||||
end;
|
||||
|
||||
class destructor TFuture<T>.DestroyClass;
|
||||
@@ -77,12 +84,12 @@ end;
|
||||
|
||||
class function TFuture<T>.Construct(const Proc: TFunc<T>): IMycFuture<T>;
|
||||
begin
|
||||
Result := TMycInitStateFuncFuture<T>.Create( TaskManager, nil, Proc );
|
||||
Result := TMycGateFuncFuture<T>.Create( TaskManager, nil, Proc );
|
||||
end;
|
||||
|
||||
class function TFuture<T>.Construct(const Gate: IMycState; const Proc: TFunc<T>): IMycFuture<T>;
|
||||
begin
|
||||
Result := TMycInitStateFuncFuture<T>.Create( TaskManager, Gate, Proc );
|
||||
Result := TMycGateFuncFuture<T>.Create( TaskManager, Gate, Proc );
|
||||
end;
|
||||
|
||||
function TFuture<T>.GetDone: IMycState;
|
||||
|
||||
Reference in New Issue
Block a user