delphidelphi-10.2-tokyoomnithreadlibrary

IOmniPipeline - 2nd stage is not getting executed


I have a simple implementation of pipeline (IOmniPipeline) but the 2nd stage that is added is not being executed.

Code follows:

 var
  OmniPipeline: IOmniPipeline;

 begin
  OmniPipeline := Parallel.Pipeline;
  OmniPipeline.Stage(DoDataTransfer_A); 
  OmniPipeline.Stage(DoDataTransfer_B); // <---- This stage is not being executed!
  OmniPipeline.OnStop(DataTransferCompleteEvent).Run;
  OmniPipeline.input.Add(nil);
  OmniPipeline.input.CompleteAdding;


procedure DoDataTransfer_A(const input: TOmniValue; var output: TOmniValue);
begin
 //some code here
end;

procedure DoDataTransfer_B(const input: TOmniValue; var output: TOmniValue);
begin
 //some code here
end;

I expect that the procedure DoDataTransfer_B should execute as soon as DoDataTransfer_A is completed (The implementations of these methods are simple and I have not included them in the question).

I would really appreciate it if you could point out what is wrong and how this can be resolved.


Solution

  • "I expect that the procedure DoDataTransfer_B should execute as soon as DoDataTransfer_A is completed."

    No, stages do not have to execute sequentially - they can execute simultaneously, that is one of the points of using a pipeline. DoDataTransfer_B will execute as soon as you pass it an input, i.e.:

    procedure DoDataTransfer_A(const input: TOmniValue; var output: TOmniValue);
    var
      InputItem: TOmniValue;
    begin
      ....
      Output.Add(InputItem); // InputItem could be input param directly, or any other input
    end;
    

    I suspect you have not done that. Hence, showing your coding would be relevant.