|
|
The following code shows a simple ProducerStage. It takes a list of elements are sends them to the ongoing stage.
|
|
|
The following code shows a simple producer stage. It takes a list of elements are sends them to the ongoing stage.
|
|
|
|
|
|
```java
|
|
|
package teetime.stage;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
import teetime.framework.AbstractProducerStage;
|
|
|
|
|
|
public final class InitialElementProducer<T> extends AbstractProducerStage<T> {
|
|
|
|
|
|
private Iterable<T> elements;
|
... | ... | @@ -41,7 +35,7 @@ Furthermore, we want to check if the given iterable is not null. |
|
|
This can be achieved by running a check while starting the stage.
|
|
|
For this, we override the method ``onStarting`` and add a null check to it.
|
|
|
This method will be called once by the framework before it executes the stage for the first time.
|
|
|
**Note:** You also need to make sure that the super method is also called.
|
|
|
**Note:** You also need to make sure the super method is also called.
|
|
|
|
|
|
Finally, we want to terminate the stage.
|
|
|
Calling the method ``terminate`` will do so and additionally send a signal to all ongoing stages to terminate. |