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 @@
1use crate::{AppContext, PlatformDispatcher};1use crate::{AppContext, PlatformDispatcher};
2use futures::{channel::mpsc, pin_mut};2use futures::{channel::mpsc, pin_mut, FutureExt};
3use smol::prelude::*;3use smol::prelude::*;
4use std::{4use std::{
5 fmt::Debug,5 fmt::Debug,
@@ -162,20 +162,16 @@ impl Executor { · 156 unmodified lines
162 duration: Duration,162 duration: Duration,
163 future: impl Future<Output = R>,163 future: impl Future<Output = R>,
164 ) -> Result<R, impl Future<Output = R>> {164 ) -> Result<R, impl Future<Output = R>> {
165 let mut future = Box::pin(future);165 let mut future = Box::pin(future.fuse());
166 if duration.is_zero() {166 if duration.is_zero() {
167 return Err(future);167 return Err(future);
168 }168 }
169 169
170 let timeout = {170 let mut timer = self.timer(duration).fuse();
171 let future = &mut future;171 let timeout = async {
172 async {172 futures::select_biased! {
173 let timer = async {173 value = future => Ok(value),
174 self.timer(duration).await;174 _ = timer => Err(()),
175 Err(())
176 };
177 let future = async move { Ok(future.await) };
178 timer.race(future).await
179 }175 }
180 };176 };
181 match self.block(timeout) {177 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