Merge pull request #1464 from zed-industries/lower-latency

Lower terminal latency
This commit is contained in:
Mikayla Maki 2022-08-03 12:21:30 -07:00 committed by GitHub
commit 9c3b287a61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -356,8 +356,14 @@ impl TerminalBuilder {
use futures::StreamExt;
while let Some(event) = self.events_rx.next().await {
let mut timer = cx.background().timer(Duration::from_millis(2)).fuse();
let mut events = vec![event];
this.upgrade(&cx)?.update(&mut cx, |this, cx| {
//Process the first event immediately for lowered latency
this.process_event(&event, cx);
});
'outer: loop {
let mut events = vec![];
let mut timer = cx.background().timer(Duration::from_millis(4)).fuse();
loop {
futures::select_biased! {
@ -375,14 +381,19 @@ impl TerminalBuilder {
}
}
if events.len() == 0 {
smol::future::yield_now().await;
break 'outer;
} else {
this.upgrade(&cx)?.update(&mut cx, |this, cx| {
for event in events {
this.process_event(&event, cx);
}
});
smol::future::yield_now().await;
}
}
}
Some(())
})