mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-03 17:44:30 +00:00
Reworked loop to lower latency and continue throttling until it's out of events
This commit is contained in:
parent
ed3d339dec
commit
4126e977b6
1 changed files with 34 additions and 23 deletions
|
@ -356,8 +356,14 @@ impl TerminalBuilder {
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
|
|
||||||
while let Some(event) = self.events_rx.next().await {
|
while let Some(event) = self.events_rx.next().await {
|
||||||
let mut timer = cx.background().timer(Duration::from_millis(2)).fuse();
|
this.upgrade(&cx)?.update(&mut cx, |this, cx| {
|
||||||
let mut events = vec![event];
|
//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 {
|
loop {
|
||||||
futures::select_biased! {
|
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| {
|
this.upgrade(&cx)?.update(&mut cx, |this, cx| {
|
||||||
for event in events {
|
for event in events {
|
||||||
this.process_event(&event, cx);
|
this.process_event(&event, cx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
smol::future::yield_now().await;
|
smol::future::yield_now().await;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Some(())
|
Some(())
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue