1 cfg_rt! {
2     pub(crate) use crate::runtime::spawn_blocking;
3     pub(crate) use crate::task::JoinHandle;
4 }
5 
6 cfg_not_rt! {
7     use std::fmt;
8     use std::future::Future;
9     use std::pin::Pin;
10     use std::task::{Context, Poll};
11 
12     pub(crate) fn spawn_blocking<F, R>(_f: F) -> JoinHandle<R>
13     where
14         F: FnOnce() -> R + Send + 'static,
15         R: Send + 'static,
16     {
17         assert_send_sync::<JoinHandle<std::cell::Cell<()>>>();
18         panic!("requires the `rt` Tokio feature flag")
19 
20     }
21 
22     pub(crate) struct JoinHandle<R> {
23         _p: std::marker::PhantomData<R>,
24     }
25 
26     unsafe impl<T: Send> Send for JoinHandle<T> {}
27     unsafe impl<T: Send> Sync for JoinHandle<T> {}
28 
29     impl<R> Future for JoinHandle<R> {
30         type Output = Result<R, std::io::Error>;
31 
32         fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Self::Output> {
33             unreachable!()
34         }
35     }
36 
37     impl<T> fmt::Debug for JoinHandle<T>
38     where
39         T: fmt::Debug,
40     {
41         fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
42             fmt.debug_struct("JoinHandle").finish()
43         }
44     }
45 
46     fn assert_send_sync<T: Send + Sync>() {
47     }
48 }
49