Skip to content

Commit

Permalink
Fix comparison to allow item buffers to be filled completely. (#54)
Browse files Browse the repository at this point in the history
The comparison to buffer capacity should be `>`, not `>=`. The current comparison prevents the item buffers from ever being totally full, which implies that the final shard written from each buffer is smaller than the others by `sender_buffer_size`
  • Loading branch information
macklin-10x authored Aug 27, 2024
1 parent 60412ad commit e75937d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,15 @@ impl<T, H: BufHandler<T>> BufferStateMachine<T, H> {
let (mut new_state, outcome) = match current_state {
FillAndWait(mut f, w) => {
f.append(items);
if f.len() + self.sender_buffer_size >= f.capacity() {
if f.len() + self.sender_buffer_size > f.capacity() {
(FillAndBusy(w), Process(f))
} else {
(FillAndWait(f, w), Done)
}
}
FillAndBusy(mut f) => {
f.append(items);
if f.len() + self.sender_buffer_size >= f.capacity() {
if f.len() + self.sender_buffer_size > f.capacity() {
(BothBusy, Process(f))
} else {
(FillAndBusy(f), Done)
Expand Down

0 comments on commit e75937d

Please sign in to comment.