    

 ## On this page

  

 

 # utility:make producer consumer for each iterator

 Last update: 31.07.2026 

**Version: 0.0.0**

## Description

Generates an iterator that can be consumed by the for\_each operator.The chain of Operators are split into a first part : the producers and a second part : the consumers.Asynchronous buffers are indeed to connect the producers and the consumers.

## Inputs

This table lists the input pins for this operator. Input pins define the data that the operator requires to perform its operation. Some inputs are required, while others are optional and provide additional configuration. Each parameter is detailed in the sections that follow the table.

Pin numberNameStatusExpected type(s)**-1**[try\_generate\_iterable](#input_-1)[`bool`](../../core-concepts/dpf-types.md#standard-types)0[iterable](#input_0)**1**[operator\_to\_iterate](#input_1)Required[`operator`](../../core-concepts/dpf-types.md#operator)**2**[pin\_index](#input_2)Required[`int32`](../../core-concepts/dpf-types.md#standard-types)**3**[valueA](#input_3)Required**4**[valueB](#input_4)Required**5**[valueC](#input_5)Required**1000**[producer\_op1](#input_1000)Required[`operator`](../../core-concepts/dpf-types.md#operator)**1001**[output\_pin\_of\_producer\_op1](#input_1001)Required[`int32`](../../core-concepts/dpf-types.md#standard-types)**1002**[input\_pin\_of\_consumer\_op1](#input_1002)Required[`int32`](../../core-concepts/dpf-types.md#standard-types)**1003**[consumer\_op1](#input_1003)Required[`operator`](../../core-concepts/dpf-types.md#operator)<a id="input_-1"></a>

### try\_generate\_iterable (Pin -1)

- **Required:** No
- **Expected type(s):** [`bool`](../../core-concepts/dpf-types.md#standard-types)

if true, already iterable values connected in pin 3 like vectors, Scoping, TimefreqSupport, Containers and DataSources are split to iterate on it (default is true)

<a id="input_0"></a>

### iterable (Pin 0)

- **Required:** No
- **Expected type(s):**

Iterable object, generated by make\_for\_each\_range oeprator, that can be combined with the one currently generated.

<a id="input_1"></a>

### operator\_to\_iterate (Pin 1)

- **Required:** Yes
- **Expected type(s):** [`operator`](../../core-concepts/dpf-types.md#operator)

Operator that must be reconnected with the range values.

<a id="input_2"></a>

### pin\_index (Pin 2)

- **Required:** Yes
- **Expected type(s):** [`int32`](../../core-concepts/dpf-types.md#standard-types)

<a id="input_3"></a>

### valueA (Pin 3)

- **Required:** Yes
- **Expected type(s):**

<a id="input_4"></a>

### valueB (Pin 4)

- **Required:** Yes
- **Expected type(s):**

<a id="input_5"></a>

### valueC (Pin 5)

- **Required:** Yes
- **Expected type(s):**

<a id="input_1000"></a>

### producer\_op1 (Pin 1000)

- **Required:** Yes
- **Expected type(s):** [`operator`](../../core-concepts/dpf-types.md#operator)

<a id="input_1001"></a>

### output\_pin\_of\_producer\_op1 (Pin 1001)

- **Required:** Yes
- **Expected type(s):** [`int32`](../../core-concepts/dpf-types.md#standard-types)

<a id="input_1002"></a>

### input\_pin\_of\_consumer\_op1 (Pin 1002)

- **Required:** Yes
- **Expected type(s):** [`int32`](../../core-concepts/dpf-types.md#standard-types)

<a id="input_1003"></a>

### consumer\_op1 (Pin 1003)

- **Required:** Yes
- **Expected type(s):** [`operator`](../../core-concepts/dpf-types.md#operator)

## Outputs

This table lists the output pins for this operator. Output pins provide the results of the operator's computation and can be connected to inputs of other operators or retrieved for further processing. Each output is detailed in the sections that follow the table.

Pin numberNameExpected type(s)0[iterator](#output_0)<a id="output_0"></a>

### iterator (Pin 0)

- **Expected type(s):**

to connect to producer\_consumer\_for\_each

## Configurations

This operator supports [configuration options](../../core-concepts/operator-configurations.md) that modify its behavior.

### [mutex](../../core-concepts/operator-configurations.md#mutex)

- **Expected type(s):** [`bool`](../../core-concepts/dpf-types.md#standard-types)
- **Default value:** false

If this option is set to true, the shared memory is prevented from being simultaneously accessed by multiple threads.

## Scripting

This operator can be accessed through scripting interfaces using these identifiers.

**Category**: utility

**Plugin**: core

**Scripting name**: make\_producer\_consumer\_for\_each\_iterator

**Full name**: utility.make\_producer\_consumer\_for\_each\_iterator

**Internal name**: make\_producer\_consumer\_for\_each\_iterator

**License**: None

## Examples

These examples demonstrate how to use this operator in different programming environments. Each example shows how to instantiate the operator, connect the required inputs, and retrieve the output.

C++```cpp
#include "dpf_api.h"

ansys::dpf::Operator op("make_producer_consumer_for_each_iterator"); // operator instantiation
op.connect(-1, my_try_generate_iterable);
op.connect(0, my_iterable);
op.connect(1, my_operator_to_iterate);
op.connect(2, my_pin_index);
op.connect(3, my_valueA);
op.connect(4, my_valueB);
op.connect(5, my_valueC);
op.connect(1000, my_producer_op1);
op.connect(1001, my_output_pin_of_producer_op1);
op.connect(1002, my_input_pin_of_consumer_op1);
op.connect(1003, my_consumer_op1);
 my_iterator = op.getOutput<>(0);

```

CPython```python
import ansys.dpf.core as dpf

op = dpf.operators.utility.make_producer_consumer_for_each_iterator() # operator instantiation
op.inputs.try_generate_iterable.connect(my_try_generate_iterable)
op.inputs.iterable.connect(my_iterable)
op.inputs.operator_to_iterate.connect(my_operator_to_iterate)
op.inputs.pin_index.connect(my_pin_index)
op.inputs.valueA.connect(my_valueA)
op.inputs.valueB.connect(my_valueB)
op.inputs.valueC1.connect(my_valueC1)
op.inputs.valueC2.connect(my_valueC2)
op.inputs.producer_op11.connect(my_producer_op11)
op.inputs.producer_op12.connect(my_producer_op12)
op.inputs.output_pin_of_producer_op11.connect(my_output_pin_of_producer_op11)
op.inputs.output_pin_of_producer_op12.connect(my_output_pin_of_producer_op12)
op.inputs.input_pin_of_consumer_op11.connect(my_input_pin_of_consumer_op11)
op.inputs.input_pin_of_consumer_op12.connect(my_input_pin_of_consumer_op12)
op.inputs.consumer_op11.connect(my_consumer_op11)
op.inputs.consumer_op12.connect(my_consumer_op12)
my_iterator = op.outputs.iterator()

```

IPython```python
import mech_dpf
import Ans.DataProcessing as dpf

op = dpf.operators.utility.make_producer_consumer_for_each_iterator() # operator instantiation
op.inputs.try_generate_iterable.Connect(my_try_generate_iterable)
op.inputs.iterable.Connect(my_iterable)
op.inputs.operator_to_iterate.Connect(my_operator_to_iterate)
op.inputs.pin_index.Connect(my_pin_index)
op.inputs.valueA.Connect(my_valueA)
op.inputs.valueB.Connect(my_valueB)
op.inputs.valueC.Connect(my_valueC)
op.inputs.producer_op1.Connect(my_producer_op1)
op.inputs.output_pin_of_producer_op1.Connect(my_output_pin_of_producer_op1)
op.inputs.input_pin_of_consumer_op1.Connect(my_input_pin_of_consumer_op1)
op.inputs.consumer_op1.Connect(my_consumer_op1)
my_iterator = op.outputs.iterator.GetData()

```

  
## Changelog

- Version 0.0.0: Initial release.