diff --git a/tokio/src/runtime/scheduler/current_thread/mod.rs b/tokio/src/runtime/scheduler/current_thread/mod.rs index e8018ab49..0b0ff5eeb 100644 --- a/tokio/src/runtime/scheduler/current_thread/mod.rs +++ b/tokio/src/runtime/scheduler/current_thread/mod.rs @@ -4,8 +4,10 @@ use crate::runtime::driver::{self, Driver}; use crate::runtime::scheduler::{self, Defer, Inject}; use crate::runtime::task::{self, JoinHandle, OwnedTasks, Schedule, SpawnLocation, Task}; use crate::runtime::{ - blocking, context, Config, MetricsBatch, SchedulerMetrics, TaskHooks, TaskMeta, WorkerMetrics, + blocking, context, Config, MetricsBatch, SchedulerMetrics, TaskHooks, WorkerMetrics, }; +#[cfg(tokio_unstable)] +use crate::runtime::TaskMeta; use crate::sync::notify::Notify; use crate::util::atomic_cell::AtomicCell; use crate::util::{waker_ref, RngSeedGenerator, Wake, WakerRef}; diff --git a/tokio/src/runtime/scheduler/multi_thread/handle.rs b/tokio/src/runtime/scheduler/multi_thread/handle.rs index 7fefc577c..39a541926 100644 --- a/tokio/src/runtime/scheduler/multi_thread/handle.rs +++ b/tokio/src/runtime/scheduler/multi_thread/handle.rs @@ -5,8 +5,10 @@ use crate::runtime::task::{Notified, Task}; use crate::runtime::{ blocking, driver, task::{self, JoinHandle, SpawnLocation}, - TaskHooks, TaskMeta, TimerFlavor, + TaskHooks, TimerFlavor, }; +#[cfg(tokio_unstable)] +use crate::runtime::TaskMeta; use crate::util::RngSeedGenerator; use std::fmt; diff --git a/tokio/src/runtime/task/list.rs b/tokio/src/runtime/task/list.rs index 884507675..2d3ad2b6e 100644 --- a/tokio/src/runtime/task/list.rs +++ b/tokio/src/runtime/task/list.rs @@ -84,34 +84,6 @@ impl OwnedTasks { } } - /// Binds the provided task to this `OwnedTasks` instance. This fails if the - /// `OwnedTasks` has been closed. - #[cfg_attr(tokio_unstable, allow(dead_code))] - pub(crate) fn bind( - &self, - task: T, - scheduler: S, - id: super::Id, - spawned_at: SpawnLocation, - #[cfg(tokio_unstable)] user_data: Option, - ) -> (JoinHandle, Option>) - where - S: Schedule, - T: Future + Send + 'static, - T::Output: Send + 'static, - { - let (task, notified, join) = super::new_task( - task, - scheduler, - id, - spawned_at, - #[cfg(tokio_unstable)] - user_data, - ); - let notified = unsafe { self.bind_inner(task, notified) }; - (join, notified) - } - pub(crate) fn bind_with_spawn_hook( &self, task: T, @@ -139,37 +111,6 @@ impl OwnedTasks { (join, notified) } - /// Bind a task that isn't safe to transfer across thread boundaries. - /// - /// # Safety - /// - /// Only use this in `LocalRuntime` where the task cannot move - #[cfg_attr(tokio_unstable, allow(dead_code))] - pub(crate) unsafe fn bind_local( - &self, - task: T, - scheduler: S, - id: super::Id, - spawned_at: SpawnLocation, - #[cfg(tokio_unstable)] user_data: Option, - ) -> (JoinHandle, Option>) - where - S: Schedule, - T: Future + 'static, - T::Output: 'static, - { - let (task, notified, join) = super::new_task( - task, - scheduler, - id, - spawned_at, - #[cfg(tokio_unstable)] - user_data, - ); - let notified = unsafe { self.bind_inner(task, notified) }; - (join, notified) - } - /// # Safety /// /// Only use this in `LocalRuntime` where the task cannot move. diff --git a/tokio/src/runtime/tests/task.rs b/tokio/src/runtime/tests/task.rs index 865d0ccd3..793ff03b7 100644 --- a/tokio/src/runtime/tests/task.rs +++ b/tokio/src/runtime/tests/task.rs @@ -2,6 +2,7 @@ use crate::runtime::task::{ self, unowned, Id, JoinHandle, OwnedTasks, Schedule, SpawnLocation, Task, }; use crate::runtime::tests::NoopSchedule; +use crate::runtime::TaskHooks; use std::collections::VecDeque; use std::future::Future; @@ -421,13 +422,22 @@ impl Runtime { T: 'static + Send + Future, T::Output: 'static + Send, { - let (handle, notified) = self.0.owned.bind( + let task_hooks = TaskHooks { + task_spawn_callback: None, + task_terminate_callback: None, + #[cfg(tokio_unstable)] + before_poll_callback: None, + #[cfg(tokio_unstable)] + after_poll_callback: None, + }; + let (handle, notified) = self.0.owned.bind_with_spawn_hook( future, self.clone(), Id::next(), SpawnLocation::capture(), #[cfg(tokio_unstable)] None, + &task_hooks, ); if let Some(notified) = notified {