docs: explain backpressure rationale for PTY event channel in
This commit is contained in:
parent
f16dc74a7a
commit
ac436abac6
2 changed files with 8 additions and 1 deletions
|
|
@ -3622,6 +3622,10 @@ impl Application for App {
|
||||||
stream::channel(
|
stream::channel(
|
||||||
100,
|
100,
|
||||||
|mut output: iced::futures::channel::mpsc::Sender<Message>| async move {
|
|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);
|
let (event_tx, mut event_rx) = mpsc::channel(1024);
|
||||||
output.send(Message::TermEventTx(event_tx)).await.unwrap();
|
output.send(Message::TermEventTx(event_tx)).await.unwrap();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,10 @@ pub struct EventProxy(
|
||||||
|
|
||||||
impl EventListener for EventProxy {
|
impl EventListener for EventProxy {
|
||||||
fn send_event(&self, event: Event) {
|
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));
|
let _ = self.2.blocking_send((self.0, self.1, event));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue