diff --git a/tokio/src/runtime/local_runtime/runtime.rs b/tokio/src/runtime/local_runtime/runtime.rs index a82d17b33e3..2470947fda1 100644 --- a/tokio/src/runtime/local_runtime/runtime.rs +++ b/tokio/src/runtime/local_runtime/runtime.rs @@ -111,11 +111,12 @@ impl LocalRuntime { &self.handle } - /// Spawns a future onto the `LocalRuntime`. + /// Spawns a task which isn't `Send + Sync` on the runtime. /// - /// See the documentation for the equivalent method on [Runtime] for more information + /// This is analogous to the [spawn] method on the standard [Runtime]. /// - /// [Runtime]: crate::runtime::Runtime::spawn + /// [spawn]: crate::runtime::Runtime::spawn + /// [Runtime]: crate::runtime::Runtime /// /// # Examples /// @@ -127,26 +128,12 @@ impl LocalRuntime { /// let rt = LocalRuntime::new().unwrap(); /// /// // Spawn a future onto the runtime - /// rt.spawn(async { + /// rt.spawn_local(async { /// println!("now running on a worker thread"); /// }); /// # } /// ``` #[track_caller] - pub fn spawn(&self, future: F) -> JoinHandle - where - F: Future + Send + 'static, - F::Output: Send + 'static, - { - if cfg!(debug_assertions) && std::mem::size_of::() > BOX_FUTURE_THRESHOLD { - self.handle.spawn_named(Box::pin(future), None) - } else { - self.handle.spawn_named(future, None) - } - } - - /// Spawns a task which isn't `Send + Sync` on the runtime. - #[track_caller] pub fn spawn_local(&self, future: F) -> JoinHandle where F: Future + 'static,