Jump to content
Epo

Pipeline questioning

Recommended Posts

Hi,

 

I want use a pipeline. The only peculiarity is that in the first stage, there is only on item in the input but many in the output collection.

But in the stage one, when it insert the first output, the exception 'Adding to completed collection'" occurs.

Although the Input.CompleteAdding statement was not sent. Something is wrong certainly but where  ?

 

Thanks for help,

 

Eddy

 

Simplified case below (using Delphi 10.4/ Omnithread 3.07.08)

procedure TForm1.Button1Click(Sender: TObject);
begin
  PipelineExecute('1,2,3,4,6,10');
end;

procedure TForm1.PipelineExecute(const sMes: string);
var
  ppl: IOmniPipeline;
  Value: TOmniValue;
begin
  ppl := Parallel.Pipeline
    .Stage(StageOne)
    .Stage(StageTwo)
    .run;

  ppl.Input.Add(sxmlMes);
//  ppl.Input.CompleteAdding;
end;


procedure TForm1.StageOne(const input, output: IOmniBlockingCollection);
var
  s: string;
  OmVal: TOmniValue;
  arS: TArray<string>;
  i: Integer;
begin
  input.Take(OmVal); // 0
  arS := SplitString(OmVal.AsString,',');
  for i := 0 to Length(arS) -1 do
    Output.Add( StrToInt(ars[i])* 2);
end;

procedure TForm1.StageTwo(const input, output: IOmniBlockingCollection);
var
  i: Integer;
  OmVal: TOmniValue;
begin
  for OmVal in input do
  begin
    //.......
    output.Add(omval) ;
  end;
end;

 

Share this post


Link to post

Your pipeline is a local variable in `TForm1.PipelineExecute`. When this method exits, `ppl` goes out of scope and is destroyed. 

 

Put the pipeline in a form field.

Share this post


Link to post

Yes, of course... (it works)

 

Great thanks for the help and ....the library.

 

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×