summaryrefslogtreecommitdiffstats
path: root/tokio/src/runtime/builder.rs
diff options
context:
space:
mode:
authorAlice Ryhl <alice@ryhl.io>2020-02-27 23:03:18 +0100
committerGitHub <noreply@github.com>2020-02-27 14:03:18 -0800
commitf0d18653a6b269d88a61ab37a00abd586b2de173 (patch)
tree6fd2b072d15273adba1217a655b05a4ae880b077 /tokio/src/runtime/builder.rs
parent06bcbe8dcf52a464d8e89866449397df1c794338 (diff)
runtime: add threaded_scheduler to examples (#2277)
It can be pretty confusing when the core_threads example does not call threaded_scheduler, when actually building such a runtime results in panics if you try to spawn something on it: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=866b3af344b0d6aad170ac9cbc9d57ed
Diffstat (limited to 'tokio/src/runtime/builder.rs')
-rw-r--r--tokio/src/runtime/builder.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/tokio/src/runtime/builder.rs b/tokio/src/runtime/builder.rs
index d77581a5..dce265c0 100644
--- a/tokio/src/runtime/builder.rs
+++ b/tokio/src/runtime/builder.rs
@@ -122,6 +122,7 @@ impl Builder {
/// use tokio::runtime;
///
/// let rt = runtime::Builder::new()
+ /// .threaded_scheduler()
/// .enable_all()
/// .build()
/// .unwrap();
@@ -162,6 +163,7 @@ impl Builder {
/// use tokio::runtime;
///
/// let rt = runtime::Builder::new()
+ /// .threaded_scheduler()
/// .core_threads(4)
/// .build()
/// .unwrap();
@@ -227,6 +229,7 @@ impl Builder {
///
/// # pub fn main() {
/// let rt = runtime::Builder::new()
+ /// .threaded_scheduler()
/// .thread_stack_size(32 * 1024)
/// .build();
/// # }
@@ -248,6 +251,7 @@ impl Builder {
///
/// # pub fn main() {
/// let runtime = runtime::Builder::new()
+ /// .threaded_scheduler()
/// .on_thread_start(|| {
/// println!("thread started");
/// })
@@ -274,6 +278,7 @@ impl Builder {
///
/// # pub fn main() {
/// let runtime = runtime::Builder::new()
+ /// .threaded_scheduler()
/// .on_thread_stop(|| {
/// println!("thread stopping");
/// })
@@ -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
@@ -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