fix tokio
This commit is contained in:
@@ -59,12 +59,25 @@ impl<T: 'static> Future for MustJoinHandle<T> {
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
match Pin::new(self.join_handle.as_mut().unwrap()).poll(cx) {
|
||||
Poll::Ready(t) => {
|
||||
if self.completed {
|
||||
panic!("should not poll completed join handle");
|
||||
}
|
||||
self.completed = true;
|
||||
cfg_if! {
|
||||
if #[cfg(feature="rt-async-std")] {
|
||||
Poll::Ready(t)
|
||||
} else if #[cfg(feature="rt-tokio")] {
|
||||
Poll::Ready(t.unwrap())
|
||||
match t {
|
||||
Ok(t) => Poll::Ready(t),
|
||||
Err(e) => {
|
||||
if e.is_panic() {
|
||||
// Resume the panic on the main task
|
||||
std::panic::resume_unwind(e.into_panic());
|
||||
} else {
|
||||
panic!("join error was not a panic, should not poll after abort");
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if #[cfg(target_arch = "wasm32")] {
|
||||
Poll::Ready(t)
|
||||
} else {
|
||||
|
||||
@@ -202,7 +202,7 @@ cfg_if! {
|
||||
}
|
||||
// Run if we should do that
|
||||
if run {
|
||||
self.unlock(Some(intf::spawn_with_local_set(future)));
|
||||
self.unlock(Some(intf::spawn(future)));
|
||||
}
|
||||
// Return the prior result if we have one
|
||||
Ok((out, run))
|
||||
|
||||
Reference in New Issue
Block a user