Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rt: move Runtime into its own file #5159

Merged
merged 2 commits into from Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions tokio/src/lib.rs
@@ -1,6 +1,7 @@
#![allow(
clippy::cognitive_complexity,
clippy::large_enum_variant,
clippy::module_inception,
clippy::needless_doctest_main
)]
#![warn(
Expand Down
22 changes: 10 additions & 12 deletions tokio/src/runtime/builder.rs
Expand Up @@ -872,7 +872,7 @@ impl Builder {

fn build_current_thread_runtime(&mut self) -> io::Result<Runtime> {
use crate::runtime::scheduler::{self, CurrentThread};
use crate::runtime::{Config, Scheduler};
use crate::runtime::{runtime::Scheduler, Config};

let (driver, driver_handle) = driver::Driver::new(self.get_cfg())?;

Expand Down Expand Up @@ -905,13 +905,15 @@ impl Builder {
},
);

let handle = scheduler::Handle::CurrentThread(scheduler.handle().clone());
let handle = Handle {
inner: scheduler::Handle::CurrentThread(scheduler.handle().clone()),
};

Ok(Runtime {
scheduler: Scheduler::CurrentThread(scheduler),
handle: Handle { inner: handle },
Ok(Runtime::from_parts(
Scheduler::CurrentThread(scheduler),
handle,
blocking_pool,
})
))
}
}

Expand Down Expand Up @@ -991,7 +993,7 @@ cfg_rt_multi_thread! {
impl Builder {
fn build_threaded_runtime(&mut self) -> io::Result<Runtime> {
use crate::loom::sys::num_cpus;
use crate::runtime::{Config, Scheduler};
use crate::runtime::{Config, runtime::Scheduler};
use crate::runtime::scheduler::{self, MultiThread};

let core_threads = self.worker_threads.unwrap_or_else(num_cpus);
Expand Down Expand Up @@ -1032,11 +1034,7 @@ cfg_rt_multi_thread! {
let _enter = handle.enter();
launch.launch();

Ok(Runtime {
scheduler: Scheduler::MultiThread(scheduler),
handle,
blocking_pool,
})
Ok(Runtime::from_parts(Scheduler::MultiThread(scheduler), handle, blocking_pool))
}
}
}
Expand Down