Skip to content

Commit

Permalink
merged_tree: extract polling of tree futures into a function
Browse files Browse the repository at this point in the history
  • Loading branch information
martinvonz committed Nov 7, 2023
1 parent f062d32 commit 51a5965
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/src/merged_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1170,13 +1170,8 @@ impl<'matcher> TreeDiffStreamImpl<'matcher> {
}
}
}
}

impl Stream for TreeDiffStreamImpl<'_> {
type Item = (RepoPath, BackendResult<(MergedTreeValue, MergedTreeValue)>);

fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
// Go through all pending tree futures and poll them.
fn poll_tree_futures(&mut self, cx: &mut Context<'_>) {
let mut pending_index = 0;
while pending_index < self.pending_trees.len()
&& (pending_index < self.max_concurrent_reads
Expand Down Expand Up @@ -1205,6 +1200,15 @@ impl Stream for TreeDiffStreamImpl<'_> {
pending_index += 1;
}
}
}
}

impl Stream for TreeDiffStreamImpl<'_> {
type Item = (RepoPath, BackendResult<(MergedTreeValue, MergedTreeValue)>);

fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
// Go through all pending tree futures and poll them.
self.poll_tree_futures(cx);

// Now emit the first file, or the first tree that completed with an error
if let Some(entry) = self.items.first_entry() {
Expand Down

0 comments on commit 51a5965

Please sign in to comment.