1

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.

Steve F
  • 1,527
  • 1
  • 29
  • 55
  • 1
    can you post a complete example? Maybe DoDataTransfer_A fails, who knows? – whosrdaddy Mar 07 '21 at 17:25
  • @whosrdaddy I can confirm that `DoDataTransfer_A ` procedure is completing correctly because it has logging inside, and I am seeing that it is executing completely. I have updated the question to add the method signatures of the 2 procedures. – Steve F Mar 07 '21 at 17:51
  • I guess your problem is that you lose references to the pipeline in the middle of stage A, which causes it to destroy after stage A completes and therefore will not proceed with stage B. Is `OmniPipeline` a local variable of some procedure? Try putting `OmniPipeline.WaitFor(INFINITE);` before the exit from procedure. – Peter Wolf Mar 08 '21 at 15:08

1 Answers1

1

"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.

RaelB
  • 3,301
  • 5
  • 35
  • 55