Skip to content

Commit

Permalink
avoid-micro-batching
Browse files Browse the repository at this point in the history
  • Loading branch information
pragmaxim committed Jun 11, 2024
1 parent cc86a28 commit 5fb2c23
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ where
let mut me = self.as_mut().project();
loop {
match me.stream.as_mut().poll_next(cx) {
Poll::Pending => break,
Poll::Pending => {
return Poll::Pending;
}
Poll::Ready(Some(item)) => {
if me.items.is_empty() {
me.items.reserve(*me.min_batch_size);
Expand All @@ -141,18 +143,10 @@ where
*me.current_batch_size = 0;
Some(std::mem::take(me.items))
};

return Poll::Ready(last);
}
}
}

if !me.items.is_empty() {
*me.current_batch_size = 0;
return Poll::Ready(Some(std::mem::take(me.items)));
}

Poll::Pending
}
}

Expand Down

0 comments on commit 5fb2c23

Please sign in to comment.