docs: explain backpressure rationale for PTY event channel in

This commit is contained in:
Marshall Humble 2026-05-14 17:29:31 -05:00
parent f16dc74a7a
commit ac436abac6
2 changed files with 8 additions and 1 deletions

View file

@ -3622,6 +3622,10 @@ impl Application for App {
stream::channel(
100,
|mut output: iced::futures::channel::mpsc::Sender<Message>| async move {
// Bounded: when the GUI can't drain fast enough, alacritty's PTY reader
// blocks on send → kernel pipe fills → producing program is throttled by
// the OS. Capacity 1024 caps the queue depth; per-event memory depends on
// payload (Wakeup is ~100 B; Title/PtyWrite carry owned Strings).
let (event_tx, mut event_rx) = mpsc::channel(1024);
output.send(Message::TermEventTx(event_tx)).await.unwrap();

View file

@ -104,7 +104,10 @@ pub struct EventProxy(
impl EventListener for EventProxy {
fn send_event(&self, event: Event) {
//TODO: handle error
// Bounded channel; blocking_send propagates backpressure to alacritty's
// PTY reader instead of letting events accumulate. Called from alacritty's
// std::thread PTY reader (not a tokio worker), so blocking is safe and
// blocking_send won't panic.
let _ = self.2.blocking_send((self.0, self.1, event));
}
}