kernel: increase event loop queue size & error if full

This commit is contained in:
hosted-fornet 2024-08-28 17:42:08 -07:00
parent 9bd5456fb0
commit f551c13d32
2 changed files with 15 additions and 2 deletions

View File

@ -31,7 +31,7 @@ mod terminal;
mod timer;
mod vfs;
const EVENT_LOOP_CHANNEL_CAPACITY: usize = 10_000;
const EVENT_LOOP_CHANNEL_CAPACITY: usize = 100_000;
const EVENT_LOOP_DEBUG_CHANNEL_CAPACITY: usize = 50;
const TERMINAL_CHANNEL_CAPACITY: usize = 32;
const WEBSOCKET_SENDER_CHANNEL_CAPACITY: usize = 32;

View File

@ -1190,7 +1190,20 @@ impl KernelMessage {
}
pub async fn send(self, sender: &MessageSender) {
sender.send(self).await.expect("kernel message sender died");
let Err(e) = sender.try_send(self) else {
// not Err -> send successful; done here
return;
};
// its an Err: handle
match e {
tokio::sync::mpsc::error::TrySendError::Closed(_) => {
panic!("kernel message sender: receiver closed");
}
tokio::sync::mpsc::error::TrySendError::Full(_) => {
// TODO: implement backpressure
panic!("kernel overloaded with messages: TODO: implement backpressure");
}
}
}
}