You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mdbook/src/chapter_3/chapter_3_3.md
+50Lines changed: 50 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,3 +18,53 @@ The `worker.step()` call is the heart of data processing in timely dataflow. The
18
18
Importantly, this is also where we start moving data around. Until we call `worker.step()` all data are just sitting in queues. The parts of our computation that do clever things like filtering down the data, or projecting out just a few small fields, or pre-aggregating the data before we act on it, these all happen here and don't happen until we call this.
19
19
20
20
Make sure to call `worker.step()` now and again, like you would your parents.
21
+
22
+
## Stepping until caught up
23
+
24
+
The `worker.step()` method returns `true` if any dataflow operator remains incomplete — meaning it could still receive data or produce output. This includes input operators whose handles have not been dropped. A common mistake is to write:
25
+
26
+
```rust,ignore
27
+
while worker.step() {
28
+
// wait for the dataflow to finish
29
+
}
30
+
```
31
+
32
+
This loop will **never terminate** as long as any input handle is still open, because the input operator is always incomplete while it could still receive data. The system has no way to know you are done sending; from its perspective, another `input.send()` could arrive at any moment.
33
+
34
+
Instead, use a probe to step until the dataflow has caught up to the input:
The probe reports whether there are still timestamps less than the argument that could appear at the probed point in the dataflow. By stepping until `probe.less_than(input.time())` is false, you ensure the dataflow has processed everything up through the current round before moving on.
62
+
63
+
The `while worker.step()` pattern is only appropriate after all inputs have been closed (by dropping their handles), at which point it correctly runs the dataflow to completion:
0 commit comments