This commit is contained in:
noah
2026-05-29 16:25:29 -05:00
parent a3860a9f37
commit 4f2f942e18
4 changed files with 27 additions and 35 deletions
@@ -2,9 +2,7 @@ use crate::loom::sync::atomic::AtomicBool;
use crate::loom::sync::Arc; use crate::loom::sync::Arc;
use crate::runtime::driver::{self, Driver}; use crate::runtime::driver::{self, Driver};
use crate::runtime::scheduler::{self, Defer, Inject}; use crate::runtime::scheduler::{self, Defer, Inject};
use crate::runtime::task::{ use crate::runtime::task::{self, JoinHandle, OwnedTasks, Schedule, SpawnLocation, Task};
self, JoinHandle, OwnedTasks, Schedule, SpawnLocation, Task,
};
use crate::runtime::{ use crate::runtime::{
blocking, context, Config, MetricsBatch, SchedulerMetrics, TaskHooks, TaskMeta, WorkerMetrics, blocking, context, Config, MetricsBatch, SchedulerMetrics, TaskHooks, TaskMeta, WorkerMetrics,
}; };
+2 -4
View File
@@ -127,8 +127,7 @@ impl<S: 'static> OwnedTasks<S> {
T: Future + Send + 'static, T: Future + Send + 'static,
T::Output: Send + 'static, T::Output: Send + 'static,
{ {
let (task, notified, join) = let (task, notified, join) = super::new_task(task, scheduler, id, spawned_at, user_data);
super::new_task(task, scheduler, id, spawned_at, user_data);
before_bind(&task); before_bind(&task);
let notified = unsafe { self.bind_inner(task, notified) }; let notified = unsafe { self.bind_inner(task, notified) };
(join, notified) (join, notified)
@@ -183,8 +182,7 @@ impl<S: 'static> OwnedTasks<S> {
T: Future + 'static, T: Future + 'static,
T::Output: 'static, T::Output: 'static,
{ {
let (task, notified, join) = let (task, notified, join) = super::new_task(task, scheduler, id, spawned_at, user_data);
super::new_task(task, scheduler, id, spawned_at, user_data);
before_bind(&task); before_bind(&task);
let notified = unsafe { self.bind_inner(task, notified) }; let notified = unsafe { self.bind_inner(task, notified) };
(join, notified) (join, notified)
+16 -19
View File
@@ -19,7 +19,6 @@ mod noop_scheduler {
fn schedule(&self, _task: task::Notified<Self>) { fn schedule(&self, _task: task::Notified<Self>) {
unreachable!(); unreachable!();
} }
} }
} }
@@ -37,15 +36,14 @@ mod unowned_wrapper {
use tracing::Instrument; use tracing::Instrument;
let span = tracing::trace_span!("test_span"); let span = tracing::trace_span!("test_span");
let task = task.instrument(span); let task = task.instrument(span);
let (task, handle) = let (task, handle) = crate::runtime::task::unowned(
crate::runtime::task::unowned( task,
task, NoopSchedule,
NoopSchedule, Id::next(),
Id::next(), SpawnLocation::capture(),
SpawnLocation::capture(), #[cfg(tokio_unstable)]
#[cfg(tokio_unstable)] None,
None, );
);
(task.into_notified(), handle) (task.into_notified(), handle)
} }
@@ -56,15 +54,14 @@ mod unowned_wrapper {
T: std::future::Future + Send + 'static, T: std::future::Future + Send + 'static,
T::Output: Send + 'static, T::Output: Send + 'static,
{ {
let (task, handle) = let (task, handle) = crate::runtime::task::unowned(
crate::runtime::task::unowned( task,
task, NoopSchedule,
NoopSchedule, Id::next(),
Id::next(), SpawnLocation::capture(),
SpawnLocation::capture(), #[cfg(tokio_unstable)]
#[cfg(tokio_unstable)] None,
None, );
);
(task.into_notified(), handle) (task.into_notified(), handle)
} }
} }
+8 -9
View File
@@ -421,15 +421,14 @@ impl Runtime {
T: 'static + Send + Future, T: 'static + Send + Future,
T::Output: 'static + Send, T::Output: 'static + Send,
{ {
let (handle, notified) = let (handle, notified) = self.0.owned.bind(
self.0.owned.bind( future,
future, self.clone(),
self.clone(), Id::next(),
Id::next(), SpawnLocation::capture(),
SpawnLocation::capture(), #[cfg(tokio_unstable)]
#[cfg(tokio_unstable)] None,
None, );
);
if let Some(notified) = notified { if let Some(notified) = notified {
self.schedule(notified); self.schedule(notified);