Skip to content
Snippets Groups Projects
Commit f43b0eeb authored by Christian Wulf's avatar Christian Wulf
Browse files

fixed Delay filter

parent 78fd48d5
No related branches found
No related tags found
No related merge requests found
package teetime.stage.basic; package teetime.stage.basic;
import java.util.LinkedList;
import java.util.List;
import teetime.framework.AbstractStage; import teetime.framework.AbstractStage;
import teetime.framework.InputPort; import teetime.framework.InputPort;
import teetime.framework.OutputPort; import teetime.framework.OutputPort;
...@@ -10,18 +13,22 @@ public class Delay<T> extends AbstractStage { ...@@ -10,18 +13,22 @@ public class Delay<T> extends AbstractStage {
private final InputPort<Long> timestampTriggerInputPort = this.createInputPort(); private final InputPort<Long> timestampTriggerInputPort = this.createInputPort();
private final OutputPort<T> outputPort = this.createOutputPort(); private final OutputPort<T> outputPort = this.createOutputPort();
private final List<T> bufferedElements = new LinkedList<T>();
@Override @Override
public void executeWithPorts() { public void executeWithPorts() {
T element = inputPort.receive();
if (null != element) {
bufferedElements.add(element);
}
Long timestampTrigger = this.timestampTriggerInputPort.receive(); Long timestampTrigger = this.timestampTriggerInputPort.receive();
if (null == timestampTrigger) { if (null == timestampTrigger) {
return; return;
} }
// System.out.println("got timestamp; #elements: " + this.getInputPort().pipe.size());
// System.out.println("#elements: " + this.getInputPort().pipe.size()); while (!bufferedElements.isEmpty()) {
// TODO implement receiveAll() and sendMultiple() element = bufferedElements.remove(0);
while (!this.inputPort.getPipe().isEmpty()) {
T element = this.inputPort.receive();
this.send(this.outputPort, element); this.send(this.outputPort, element);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment