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

runtime: Add threaded_scheduler to examples #2277

Merged
merged 1 commit into from
Feb 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tokio/src/runtime/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ impl Builder {
/// use tokio::runtime;
///
/// let rt = runtime::Builder::new()
/// .threaded_scheduler()
/// .enable_all()
/// .build()
/// .unwrap();
Expand Down Expand Up @@ -162,6 +163,7 @@ impl Builder {
/// use tokio::runtime;
///
/// let rt = runtime::Builder::new()
/// .threaded_scheduler()
/// .core_threads(4)
/// .build()
/// .unwrap();
Expand Down Expand Up @@ -227,6 +229,7 @@ impl Builder {
///
/// # pub fn main() {
/// let rt = runtime::Builder::new()
/// .threaded_scheduler()
/// .thread_stack_size(32 * 1024)
/// .build();
/// # }
Expand All @@ -248,6 +251,7 @@ impl Builder {
///
/// # pub fn main() {
/// let runtime = runtime::Builder::new()
/// .threaded_scheduler()
/// .on_thread_start(|| {
/// println!("thread started");
/// })
Expand All @@ -274,6 +278,7 @@ impl Builder {
///
/// # pub fn main() {
/// let runtime = runtime::Builder::new()
/// .threaded_scheduler()
/// .on_thread_stop(|| {
/// println!("thread stopping");
/// })
Expand Down Expand Up @@ -395,6 +400,11 @@ cfg_rt_core! {
///
/// The executor and all necessary drivers will all be run on the current
/// thread during `block_on` calls.
///
/// See also [the module level documentation][1], which has a section on scheduler
/// types.
///
/// [1]: index.html#runtime-configurations
pub fn basic_scheduler(&mut self) -> &mut Self {
self.kind = Kind::Basic;
self
Expand Down Expand Up @@ -439,6 +449,11 @@ cfg_rt_core! {
cfg_rt_threaded! {
impl Builder {
/// Sets runtime to use a multi-threaded scheduler for executing tasks.
///
/// See also [the module level documentation][1], which has a section on scheduler
/// types.
///
/// [1]: index.html#runtime-configurations
pub fn threaded_scheduler(&mut self) -> &mut Self {
self.kind = Kind::ThreadPool;
self
Expand Down