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: rename internal runtime::Kind to Scheduler #5017

Merged
merged 2 commits into from Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions tokio/src/runtime/builder.rs
Expand Up @@ -832,7 +832,7 @@ impl Builder {
}

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

let (driver, resources) = driver::Driver::new(self.get_cfg())?;
Expand Down Expand Up @@ -869,7 +869,7 @@ impl Builder {
});

Ok(Runtime {
kind: Kind::CurrentThread(scheduler),
scheduler: Scheduler::CurrentThread(scheduler),
handle: Handle { inner },
blocking_pool,
})
Expand Down Expand Up @@ -952,7 +952,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, HandleInner, Kind, MultiThread};
use crate::runtime::{Config, HandleInner, Scheduler, MultiThread};
use std::sync::Arc;

let core_threads = self.worker_threads.unwrap_or_else(num_cpus);
Expand Down Expand Up @@ -996,7 +996,7 @@ cfg_rt_multi_thread! {
launch.launch();

Ok(Runtime {
kind: Kind::MultiThread(scheduler),
scheduler: Scheduler::MultiThread(scheduler),
handle,
blocking_pool,
})
Expand Down
20 changes: 10 additions & 10 deletions tokio/src/runtime/mod.rs
Expand Up @@ -297,8 +297,8 @@ cfg_rt! {
/// [`Builder`]: struct@Builder
#[derive(Debug)]
pub struct Runtime {
/// Task executor
kind: Kind,
/// Task scheduler
scheduler: Scheduler,

/// Handle to runtime, also contains driver handles
handle: Handle,
Expand All @@ -307,9 +307,9 @@ cfg_rt! {
blocking_pool: BlockingPool,
}

/// The runtime executor is either a multi-thread or a current-thread executor.
/// The runtime scheduler is either a multi-thread or a current-thread executor.
#[derive(Debug)]
enum Kind {
enum Scheduler {
/// Execute all tasks on the current-thread.
CurrentThread(CurrentThread),

Expand Down Expand Up @@ -491,10 +491,10 @@ cfg_rt! {

let _enter = self.enter();

match &self.kind {
Kind::CurrentThread(exec) => exec.block_on(future),
match &self.scheduler {
Scheduler::CurrentThread(exec) => exec.block_on(future),
#[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))]
Kind::MultiThread(exec) => exec.block_on(future),
Scheduler::MultiThread(exec) => exec.block_on(future),
}
}

Expand Down Expand Up @@ -609,8 +609,8 @@ cfg_rt! {
#[allow(clippy::single_match)] // there are comments in the error branch, so we don't want if-let
impl Drop for Runtime {
fn drop(&mut self) {
match &mut self.kind {
Kind::CurrentThread(current_thread) => {
match &mut self.scheduler {
Scheduler::CurrentThread(current_thread) => {
// This ensures that tasks spawned on the current-thread
// runtime are dropped inside the runtime's context.
match self::context::try_enter(self.handle.clone()) {
Expand All @@ -624,7 +624,7 @@ cfg_rt! {
}
},
#[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))]
Kind::MultiThread(_) => {
Scheduler::MultiThread(_) => {
// The threaded scheduler drops its tasks on its worker threads, which is
// already in the runtime's context.
},
Expand Down