TaskManager refactoring
This commit is contained in:
+8
-10
@@ -44,7 +44,7 @@ type
|
||||
class operator Implicit(const A: TFuture<T>): IFuture; overload;
|
||||
|
||||
class function Construct(const Proc: TFunc<T>): TFuture<T>; overload; static;
|
||||
class function Construct(const Gate: TState.IState; const Proc: TFunc<T>): TFuture<T>; overload; static;
|
||||
class function Construct(const Gate: TState; const Proc: TFunc<T>): TFuture<T>; overload; static;
|
||||
|
||||
class property Null: IFuture read FNull;
|
||||
|
||||
@@ -94,23 +94,21 @@ end;
|
||||
|
||||
function TFuture<T>.Chain(const Proc: TProcConst<T, TState>): TState;
|
||||
begin
|
||||
var Done := TLatch.CreateLatch(1);
|
||||
Result := Done.State;
|
||||
var cFuture := FFuture;
|
||||
|
||||
var future := FFuture;
|
||||
TaskManager.RunTask(future.Done, procedure begin Proc(future.Value).Subscribe(Done); end);
|
||||
Result := TaskManager.RunTask(cFuture.Done, function: TState begin Result := Proc(cFuture.Value); end);
|
||||
end;
|
||||
|
||||
function TFuture<T>.Chain<S>(const Proc: TFunc<T, S>): TFuture<S>;
|
||||
begin
|
||||
var Cap := FFuture;
|
||||
Result := TFuture<S>.Construct(FFuture.Done, function: S begin Result := Proc(Cap.Value); end);
|
||||
var cFuture := FFuture;
|
||||
Result := TFuture<S>.Construct(cFuture.Done, function: S begin Result := Proc(cFuture.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);
|
||||
var cFuture := FFuture;
|
||||
Result := TFuture<S>.Construct(cFuture.Done, function: S begin Result := Proc(cFuture.Value); end);
|
||||
end;
|
||||
|
||||
class function TFuture<T>.Construct(const Proc: TFunc<T>): TFuture<T>;
|
||||
@@ -118,7 +116,7 @@ begin
|
||||
Result := TMycGateFuncFuture<T>.Create(TaskManager, nil, Proc);
|
||||
end;
|
||||
|
||||
class function TFuture<T>.Construct(const Gate: TState.IState; const Proc: TFunc<T>): TFuture<T>;
|
||||
class function TFuture<T>.Construct(const Gate: TState; const Proc: TFunc<T>): TFuture<T>;
|
||||
begin
|
||||
Result := TMycGateFuncFuture<T>.Create(TaskManager, Gate, Proc);
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user