fix tokio

This commit is contained in:
John Smith
2022-06-29 10:13:49 -04:00
parent d3f872eb1f
commit 018d7da429
20 changed files with 115 additions and 54 deletions

View File

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

View File

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