Send the WakeUp message if necessary in the reserve function

This commit is contained in:
Kerollmops 2024-12-04 11:03:01 +01:00
parent 0459b1a242
commit 96831ed9bb
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F

View File

@ -459,12 +459,6 @@ impl<'b> ExtractorBbqueueSender<'b> {
Ok(())
})?;
// We only send a wake up message when the channel is empty
// so that we don't fill the channel with too many WakeUps.
if self.sender.is_empty() {
self.sender.send(ReceiverAction::WakeUp).unwrap();
}
Ok(())
}
@ -517,12 +511,6 @@ impl<'b> ExtractorBbqueueSender<'b> {
Ok(())
})?;
// We only send a wake up message when the channel is empty
// so that we don't fill the channel with too many WakeUps.
if self.sender.is_empty() {
self.sender.send(ReceiverAction::WakeUp).unwrap();
}
Ok(())
}
@ -587,12 +575,6 @@ impl<'b> ExtractorBbqueueSender<'b> {
key_value_writer(key_buffer, value_buffer)
})?;
// We only send a wake up message when the channel is empty
// so that we don't fill the channel with too many WakeUps.
if self.sender.is_empty() {
self.sender.send(ReceiverAction::WakeUp).unwrap();
}
Ok(())
}
@ -640,18 +622,13 @@ impl<'b> ExtractorBbqueueSender<'b> {
key_writer(remaining)
})?;
// We only send a wake up message when the channel is empty
// so that we don't fill the channel with too many WakeUps.
if self.sender.is_empty() {
self.sender.send(ReceiverAction::WakeUp).unwrap();
}
Ok(())
}
}
/// Try to reserve a frame grant of `total_length` by spin looping
/// on the BBQueue buffer and panics if the receiver has been disconnected.
/// Try to reserve a frame grant of `total_length` by spin
/// looping on the BBQueue buffer, panics if the receiver
/// has been disconnected or send a WakeUp message if necessary.
fn reserve_and_write_grant<F>(
producer: &mut FrameProducer,
total_length: usize,
@ -668,6 +645,13 @@ where
// We could commit only the used memory.
f(&mut grant)?;
grant.commit(total_length);
// We only send a wake up message when the channel is empty
// so that we don't fill the channel with too many WakeUps.
if sender.is_empty() {
sender.send(ReceiverAction::WakeUp).unwrap();
}
return Ok(());
}
Err(bbqueue::Error::InsufficientSize) => continue,