|
33 | 33 | //! tracker.update_source(Source::new(0, 0), 17, 1); |
34 | 34 | //! |
35 | 35 | //! // Propagate changes; until this call updates are simply buffered. |
36 | | -//! tracker.propagate_all(); |
| 36 | +//! let updates = tracker.propagate_all(); |
37 | 37 | //! |
38 | | -//! let mut results = |
39 | | -//! tracker |
40 | | -//! .pushed() |
41 | | -//! .drain() |
| 38 | +//! let mut results = updates |
42 | 39 | //! .filter(|((location, time), delta)| location.is_target()) |
43 | 40 | //! .collect::<Vec<_>>(); |
44 | 41 | //! |
|
55 | 52 | //! tracker.update_source(Source::new(0, 0), 17, -1); |
56 | 53 | //! |
57 | 54 | //! // Propagate changes; until this call updates are simply buffered. |
58 | | -//! tracker.propagate_all(); |
| 55 | +//! let updates = tracker.propagate_all(); |
59 | 56 | //! |
60 | | -//! let mut results = |
61 | | -//! tracker |
62 | | -//! .pushed() |
63 | | -//! .drain() |
| 57 | +//! let mut results = updates |
64 | 58 | //! .filter(|((location, time), delta)| location.is_target()) |
65 | 59 | //! .collect::<Vec<_>>(); |
66 | 60 | //! |
@@ -564,8 +558,10 @@ impl<T:Timestamp> Tracker<T> { |
564 | 558 | /// Propagates all pending updates. |
565 | 559 | /// |
566 | 560 | /// The method drains `self.input_changes` and circulates their implications |
567 | | - /// until we cease deriving new implications. |
568 | | - pub fn propagate_all(&mut self) { |
| 561 | + /// until we cease deriving new implications. It returns an iterator over updates |
| 562 | + /// to implications. |
| 563 | + pub fn propagate_all(&mut self) -> impl Iterator<Item = ((Location, T), i64)> + '_ { |
| 564 | + self.pushed_changes.clear(); |
569 | 565 |
|
570 | 566 | // Step 0: If logging is enabled, construct and log inbound changes. |
571 | 567 | if let Some(logger) = &mut self.logger { |
@@ -699,18 +695,15 @@ impl<T:Timestamp> Tracker<T> { |
699 | 695 | }; |
700 | 696 | } |
701 | 697 | } |
| 698 | + |
| 699 | + self.pushed_changes.drain() |
702 | 700 | } |
703 | 701 |
|
704 | 702 | /// Implications of maintained capabilities projected to each output. |
705 | 703 | pub fn pushed_output(&mut self) -> &mut [ChangeBatch<T>] { |
706 | 704 | &mut self.output_changes[..] |
707 | 705 | } |
708 | 706 |
|
709 | | - /// A mutable reference to the pushed results of changes. |
710 | | - pub fn pushed(&mut self) -> &mut ChangeBatch<(Location, T)> { |
711 | | - &mut self.pushed_changes |
712 | | - } |
713 | | - |
714 | 707 | /// Reveals per-operator frontier state. |
715 | 708 | pub fn node_state(&self, index: usize) -> &PerOperator<T> { |
716 | 709 | &self.per_operator[index] |
|
0 commit comments