Merge branch 'zed2' of github.com:zed-industries/zed into zed2

This commit is contained in:
Marshall Bowers
2023-10-30 10:40:48 -04:00

View File

@@ -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) {