mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-16 23:34:11 +00:00
Remove randomness from GPUI2 block_with_timeout
This commit is contained in:
parent
b3c3adab50
commit
25e882d72a
1 changed files with 7 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
|||
use crate::{AppContext, PlatformDispatcher};
|
||||
use futures::{channel::mpsc, pin_mut};
|
||||
use futures::{channel::mpsc, pin_mut, FutureExt};
|
||||
use smol::prelude::*;
|
||||
use std::{
|
||||
fmt::Debug,
|
||||
|
@ -162,20 +162,16 @@ impl Executor {
|
|||
duration: Duration,
|
||||
future: impl Future<Output = R>,
|
||||
) -> Result<R, impl Future<Output = R>> {
|
||||
let mut future = Box::pin(future);
|
||||
let mut future = Box::pin(future.fuse());
|
||||
if duration.is_zero() {
|
||||
return Err(future);
|
||||
}
|
||||
|
||||
let timeout = {
|
||||
let future = &mut future;
|
||||
async {
|
||||
let timer = async {
|
||||
self.timer(duration).await;
|
||||
Err(())
|
||||
};
|
||||
let future = async move { Ok(future.await) };
|
||||
timer.race(future).await
|
||||
let mut timer = self.timer(duration).fuse();
|
||||
let timeout = async {
|
||||
futures::select_biased! {
|
||||
value = future => Ok(value),
|
||||
_ = timer => Err(()),
|
||||
}
|
||||
};
|
||||
match self.block(timeout) {
|
||||
|
|
Loading…
Reference in a new issue