mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-27 00:00:12 +02:00
rt: remove internal runtime::ToHandle trait (#5002)
The internal `runtime::ToHandle` trait is no longer needed as the runtime handle is used everywhere now.
This commit is contained in:
@@ -7,7 +7,7 @@ use crate::runtime::blocking::{shutdown, BlockingTask};
|
||||
use crate::runtime::builder::ThreadNameFn;
|
||||
use crate::runtime::context;
|
||||
use crate::runtime::task::{self, JoinHandle};
|
||||
use crate::runtime::{Builder, Callback, ToHandle};
|
||||
use crate::runtime::{Builder, Callback, Handle};
|
||||
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::fmt;
|
||||
@@ -242,7 +242,7 @@ impl fmt::Debug for BlockingPool {
|
||||
|
||||
impl Spawner {
|
||||
#[track_caller]
|
||||
pub(crate) fn spawn_blocking<F, R>(&self, rt: &dyn ToHandle, func: F) -> JoinHandle<R>
|
||||
pub(crate) fn spawn_blocking<F, R>(&self, rt: &Handle, func: F) -> JoinHandle<R>
|
||||
where
|
||||
F: FnOnce() -> R + Send + 'static,
|
||||
R: Send + 'static,
|
||||
@@ -270,7 +270,7 @@ impl Spawner {
|
||||
all(loom, not(test)), // the function is covered by loom tests
|
||||
test
|
||||
), allow(dead_code))]
|
||||
pub(crate) fn spawn_mandatory_blocking<F, R>(&self, rt: &dyn ToHandle, func: F) -> Option<JoinHandle<R>>
|
||||
pub(crate) fn spawn_mandatory_blocking<F, R>(&self, rt: &Handle, func: F) -> Option<JoinHandle<R>>
|
||||
where
|
||||
F: FnOnce() -> R + Send + 'static,
|
||||
R: Send + 'static,
|
||||
@@ -305,7 +305,7 @@ impl Spawner {
|
||||
func: F,
|
||||
is_mandatory: Mandatory,
|
||||
name: Option<&str>,
|
||||
rt: &dyn ToHandle,
|
||||
rt: &Handle,
|
||||
) -> (JoinHandle<R>, Result<(), SpawnError>)
|
||||
where
|
||||
F: FnOnce() -> R + Send + 'static,
|
||||
@@ -337,7 +337,7 @@ impl Spawner {
|
||||
(handle, spawned)
|
||||
}
|
||||
|
||||
fn spawn_task(&self, task: Task, rt: &dyn ToHandle) -> Result<(), SpawnError> {
|
||||
fn spawn_task(&self, task: Task, rt: &Handle) -> Result<(), SpawnError> {
|
||||
let mut shared = self.inner.shared.lock();
|
||||
|
||||
if shared.shutdown {
|
||||
@@ -400,7 +400,7 @@ impl Spawner {
|
||||
fn spawn_thread(
|
||||
&self,
|
||||
shutdown_tx: shutdown::Sender,
|
||||
rt: &dyn ToHandle,
|
||||
rt: &Handle,
|
||||
id: usize,
|
||||
) -> std::io::Result<thread::JoinHandle<()>> {
|
||||
let mut builder = thread::Builder::new().name((self.inner.thread_name)());
|
||||
@@ -409,7 +409,7 @@ impl Spawner {
|
||||
builder = builder.stack_size(stack_size);
|
||||
}
|
||||
|
||||
let rt = rt.to_handle();
|
||||
let rt = rt.clone();
|
||||
|
||||
builder.spawn(move || {
|
||||
// Only the reference should be moved into the closure
|
||||
|
||||
Reference in New Issue
Block a user