parallel PathData creation
This commit is contained in:
@@ -59,6 +59,22 @@ type
|
||||
property Value: T read GetValue;
|
||||
end;
|
||||
|
||||
IObjectRef<T: class> = interface
|
||||
function GetObj: T;
|
||||
function Pop: T;
|
||||
property Obj: T read GetObj;
|
||||
end;
|
||||
|
||||
TObjectRef<T: class> = class(TInterfacedObject, IObjectRef<T>)
|
||||
private
|
||||
FObj: T;
|
||||
function GetObj: T;
|
||||
public
|
||||
constructor Create(const ARef: T);
|
||||
destructor Destroy; override;
|
||||
function Pop: T;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
@@ -144,4 +160,27 @@ begin
|
||||
Dest.FFuture := FNull;
|
||||
end;
|
||||
|
||||
constructor TObjectRef<T>.Create(const ARef: T);
|
||||
begin
|
||||
inherited Create;
|
||||
FObj := ARef;
|
||||
end;
|
||||
|
||||
destructor TObjectRef<T>.Destroy;
|
||||
begin
|
||||
FObj.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TObjectRef<T>.GetObj: T;
|
||||
begin
|
||||
Result := FObj;
|
||||
end;
|
||||
|
||||
function TObjectRef<T>.Pop: T;
|
||||
begin
|
||||
Result := FObj;
|
||||
FreeAndNil( FObj );
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
@@ -101,7 +101,7 @@ type
|
||||
// Used by cache to actually load an uncached file.
|
||||
function DoLoad(const FileName: string): TFuture<TArray<TDataPoint<T>>>;
|
||||
|
||||
function LoadFile(currFile: TAuraDataFile; Terminated: TState; Proc: TDataProc<T>): TState;
|
||||
function LoadFile(DataFile: TAuraDataFile; Terminated: TState; Proc: TDataProc<T>): TState;
|
||||
|
||||
strict private
|
||||
class var
|
||||
@@ -400,19 +400,19 @@ begin
|
||||
Result := FCachedFiles.GetOrAdd(DataFile.GetFullFileName);
|
||||
end;
|
||||
|
||||
function TAuraDataServer<T>.LoadFile(currFile: TAuraDataFile; Terminated: TState; Proc: TDataProc<T>): TState;
|
||||
function TAuraDataServer<T>.LoadFile(DataFile: TAuraDataFile; Terminated: TState; Proc: TDataProc<T>): TState;
|
||||
begin
|
||||
if not currFile.IsValid or Terminated.IsSet then
|
||||
if not DataFile.IsValid or Terminated.IsSet then
|
||||
exit(TState.Null);
|
||||
|
||||
var data := FCachedFiles.GetOrAdd(currFile.GetFullFileName);
|
||||
var data := FCachedFiles.GetOrAdd(DataFile.GetFullFileName);
|
||||
|
||||
Result :=
|
||||
data.Chain(
|
||||
function(const Data: TArray<TDataPoint<T>>): TState
|
||||
begin
|
||||
Proc(Data, Terminated);
|
||||
Result := LoadFile(currFile.GetNextFile, Terminated, Proc);
|
||||
Result := LoadFile(DataFile.GetNextFile, Terminated, Proc);
|
||||
end
|
||||
);
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user