Streamlining DataServer
This commit is contained in:
+10
-1
@@ -22,6 +22,8 @@ type
|
||||
property Done: TState read GetDone;
|
||||
end;
|
||||
|
||||
TFuncConst<T, TResult> = reference to function(const Arg1: T): TResult;
|
||||
|
||||
{$REGION 'private'}
|
||||
strict private
|
||||
class var
|
||||
@@ -47,7 +49,8 @@ type
|
||||
|
||||
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>; overload;
|
||||
function Chain<S>(const Proc: TFuncConst<T, S>): TFuture<S>; overload;
|
||||
function WaitFor: T;
|
||||
|
||||
property Done: TState read GetDone;
|
||||
@@ -84,6 +87,12 @@ begin
|
||||
Result := TFuture<S>.Construct(FFuture.Done, function: S begin Result := Proc(Cap.Value); end);
|
||||
end;
|
||||
|
||||
function TFuture<T>.Chain<S>(const Proc: TFuncConst<T, S>): TFuture<S>;
|
||||
begin
|
||||
var Cap := FFuture;
|
||||
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>;
|
||||
begin
|
||||
Result := TMycGateFuncFuture<T>.Create(TaskManager, nil, Proc);
|
||||
|
||||
Reference in New Issue
Block a user