summaryrefslogtreecommitdiffstats
path: root/tokio/src/blocking.rs
diff options
context:
space:
mode:
authorLucio Franco <luciofranco14@gmail.com>2020-10-12 13:44:54 -0400
committerGitHub <noreply@github.com>2020-10-12 13:44:54 -0400
commit8880222036f37c6204c8466f25e828447f16dacb (patch)
treefd623afc20f73bbce65746a3d1b1b2731ecf30a5 /tokio/src/blocking.rs
parent0893841f31542b2b04c5050a8a4a3c45cf867e55 (diff)
rt: Remove `threaded_scheduler()` and `basic_scheduler()` (#2876)
Co-authored-by: Alice Ryhl <alice@ryhl.io> Co-authored-by: Carl Lerche <me@carllerche.com>
Diffstat (limited to 'tokio/src/blocking.rs')
-rw-r--r--tokio/src/blocking.rs48
1 files changed, 48 insertions, 0 deletions
diff --git a/tokio/src/blocking.rs b/tokio/src/blocking.rs
new file mode 100644
index 00000000..d6ef5915
--- /dev/null
+++ b/tokio/src/blocking.rs
@@ -0,0 +1,48 @@
+cfg_rt_core! {
+ pub(crate) use crate::runtime::spawn_blocking;
+ pub(crate) use crate::task::JoinHandle;
+}
+
+cfg_not_rt_core! {
+ use std::fmt;
+ use std::future::Future;
+ use std::pin::Pin;
+ use std::task::{Context, Poll};
+
+ pub(crate) fn spawn_blocking<F, R>(_f: F) -> JoinHandle<R>
+ where
+ F: FnOnce() -> R + Send + 'static,
+ R: Send + 'static,
+ {
+ assert_send_sync::<JoinHandle<std::cell::Cell<()>>>();
+ panic!("requires the `rt-core` Tokio feature flag")
+
+ }
+
+ pub(crate) struct JoinHandle<R> {
+ _p: std::marker::PhantomData<R>,
+ }
+
+ unsafe impl<T: Send> Send for JoinHandle<T> {}
+ unsafe impl<T: Send> Sync for JoinHandle<T> {}
+
+ impl<R> Future for JoinHandle<R> {
+ type Output = Result<R, std::io::Error>;
+
+ fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Self::Output> {
+ unreachable!()
+ }
+ }
+
+ impl<T> fmt::Debug for JoinHandle<T>
+ where
+ T: fmt::Debug,
+ {
+ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
+ fmt.debug_struct("JoinHandle").finish()
+ }
+ }
+
+ fn assert_send_sync<T: Send + Sync>() {
+ }
+}