History

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

Marshall Bowers committed 3 years ago

Commit b8ae9492 parents 61cc3b9 25e882d1 file · +7 −11Browse files

Unified · Split

crates/gpui2/src/executor.rs+7−11
@@ -1,5 +1,5 @@
11 use crate::{AppContext, PlatformDispatcher};
2−use futures::{channel::mpsc, pin_mut};
2+use futures::{channel::mpsc, pin_mut, FutureExt};
33 use smol::prelude::*;
44 use std::{
55 fmt::Debug,
@@ -162,20 +162,16 @@ impl Executor { · 156 unmodified lines
162162 duration: Duration,
163163 future: impl Future<Output = R>,
164164 ) -> Result<R, impl Future<Output = R>> {
165− let mut future = Box::pin(future);
165+ let mut future = Box::pin(future.fuse());
166166 if duration.is_zero() {
167167 return Err(future);
168168 }
169169
170− let timeout = {
171− let future = &mut future;
172− async {
173− let timer = async {
174− self.timer(duration).await;
175− Err(())
176− };
177− let future = async move { Ok(future.await) };
178− timer.race(future).await
170+ let mut timer = self.timer(duration).fuse();
171+ let timeout = async {
172+ futures::select_biased! {
173+ value = future => Ok(value),
174+ _ = timer => Err(()),
179175 }
180176 };
181177 match self.block(timeout) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t