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

docs: Mention features for basic_scheduler, threaded_scheduler #1858

Merged
merged 1 commit into from Nov 29, 2019
Merged
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
32 changes: 15 additions & 17 deletions tokio/src/runtime/builder.rs
Expand Up @@ -152,23 +152,6 @@ impl Builder {
self
}

/// Use a simpler scheduler that runs all tasks on the current-thread.
///
/// The executor and all necessary drivers will all be run on the current
/// thread during `block_on` calls.
#[cfg(feature = "rt-core")]
pub fn basic_scheduler(&mut self) -> &mut Self {
self.kind = Kind::Basic;
self
}

/// Use a multi-threaded scheduler for executing tasks.
#[cfg(feature = "rt-threaded")]
pub fn threaded_scheduler(&mut self) -> &mut Self {
self.kind = Kind::ThreadPool;
self
}

/// Set name of threads spawned by the `Runtime`'s thread pool.
///
/// The default name is "tokio-runtime-worker".
Expand Down Expand Up @@ -369,6 +352,15 @@ cfg_time! {

cfg_rt_core! {
impl Builder {
/// Use a simpler scheduler that runs all tasks on the current-thread.
///
/// The executor and all necessary drivers will all be run on the current
/// thread during `block_on` calls.
pub fn basic_scheduler(&mut self) -> &mut Self {
self.kind = Kind::Basic;
self
}

fn build_basic_runtime(&mut self) -> io::Result<Runtime> {
use crate::runtime::{BasicScheduler, Kind};

Expand Down Expand Up @@ -407,6 +399,12 @@ cfg_rt_core! {

cfg_rt_threaded! {
impl Builder {
/// Use a multi-threaded scheduler for executing tasks.
pub fn threaded_scheduler(&mut self) -> &mut Self {
self.kind = Kind::ThreadPool;
self
}

fn build_threaded_runtime(&mut self) -> io::Result<Runtime> {
use crate::runtime::{Kind, ThreadPool};
use crate::runtime::park::Parker;
Expand Down