id stringlengths 22 133 | text stringlengths 40 40.2k | arch stringclasses 1
value | syntax stringclasses 1
value | kind stringclasses 4
values | repo stringclasses 27
values | path stringlengths 5 116 | license stringclasses 6
values | commit stringlengths 40 40 | source_host stringclasses 1
value | category stringclasses 16
values | source_url stringlengths 85 196 | line_start int64 1 4.28k | line_end int64 4 4.31k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokio-rs/tokio:tokio/src/runtime/builder.rs:7 | max_blocking_threads: 512,
// Default thread name
thread_name: std::sync::Arc::new(|| "tokio-runtime-worker".into()),
// Do not set a stack size by default
thread_stack_size: None,
// No worker thread callbacks
after_start: None,
bef... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | e14307393a3e04cc50b3a04a019b589a2d409d3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14307393a3e04cc50b3a04a019b589a2d409d3f/tokio/src/runtime/builder.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:12 | ///
/// # pub fn main() {
/// let rt = runtime::Builder::new_multi_thread()
/// .thread_stack_size(32 * 1024)
/// .build();
/// # }
/// ```
pub fn thread_stack_size(&mut self, val: usize) -> &mut Self {
self.thread_stack_size = Some(val);
self
}
/// Executes ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | e14307393a3e04cc50b3a04a019b589a2d409d3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14307393a3e04cc50b3a04a019b589a2d409d3f/tokio/src/runtime/builder.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:15 | /// tokio::spawn(async move { barrier.wait().await; });
/// }
/// }
/// })
/// .build()
/// .unwrap();
///
/// runtime.block_on(async {
/// barrier.wait().await;
/// })
/// # }
/// ```
#[cfg(not(loom))]
pub fn on_threa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | e14307393a3e04cc50b3a04a019b589a2d409d3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14307393a3e04cc50b3a04a019b589a2d409d3f/tokio/src/runtime/builder.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:16 | ///
/// runtime.unwrap().block_on(async {
/// tokio::task::yield_now().await;
/// println!("Hello from Tokio!");
/// })
/// # }
/// ```
#[cfg(not(loom))]
pub fn on_thread_unpark<F>(&mut self, f: F) -> &mut Self
where
F: Fn() + Send + Sync + 'static,
{
self.a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | e14307393a3e04cc50b3a04a019b589a2d409d3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14307393a3e04cc50b3a04a019b589a2d409d3f/tokio/src/runtime/builder.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:17 | driver::Cfg {
enable_pause_time: match self.kind {
Kind::CurrentThread => true,
#[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))]
Kind::MultiThread => false,
},
enable_io: self.enable_io,
enable_time: self.enable_tim... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | e14307393a3e04cc50b3a04a019b589a2d409d3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14307393a3e04cc50b3a04a019b589a2d409d3f/tokio/src/runtime/builder.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:22 | ///
/// This option is intended to make certain parts of the runtime
/// deterministic (e.g. the [`tokio::select!`] macro). In the case of
/// [`tokio::select!`] it will ensure that the order that branches are
/// polled is deterministic.
///
/// In addition to the code s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | e14307393a3e04cc50b3a04a019b589a2d409d3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14307393a3e04cc50b3a04a019b589a2d409d3f/tokio/src/runtime/builder.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:23 | let blocking_spawner = blocking_pool.spawner().clone();
// Generate a rng seed for this runtime.
let seed_generator_1 = self.seed_generator.next_generator();
let seed_generator_2 = self.seed_generator.next_generator();
// And now put a single-threaded scheduler on top of the timer. Whe... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | e14307393a3e04cc50b3a04a019b589a2d409d3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14307393a3e04cc50b3a04a019b589a2d409d3f/tokio/src/runtime/builder.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:24 | impl Builder {
/// Enables the I/O driver.
///
/// Doing this enables using net, process, signal, and some I/O types on
/// the runtime.
///
/// # Examples
///
/// ```
/// use tokio::runtime;
///
/// let rt = runtime::Builder::new_m... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | e14307393a3e04cc50b3a04a019b589a2d409d3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14307393a3e04cc50b3a04a019b589a2d409d3f/tokio/src/runtime/builder.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:25 | self.enable_time = true;
self
}
}
}
cfg_test_util! {
impl Builder {
/// Controls if the runtime's clock starts paused or advancing.
///
/// Pausing time requires the current-thread runtime; construction of
/// the runtime will panic otherwise.
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | e14307393a3e04cc50b3a04a019b589a2d409d3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14307393a3e04cc50b3a04a019b589a2d409d3f/tokio/src/runtime/builder.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:26 | let (driver, driver_handle) = driver::Driver::new(self.get_cfg())?;
// Create the blocking pool
let blocking_pool =
blocking::create_blocking_pool(self, self.max_blocking_threads + core_threads);
let blocking_spawner = blocking_pool.spawner().clone();
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | e14307393a3e04cc50b3a04a019b589a2d409d3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14307393a3e04cc50b3a04a019b589a2d409d3f/tokio/src/runtime/builder.rs | 1,001 | 1,057 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:27 | impl fmt::Debug for Builder {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Builder")
.field("worker_threads", &self.worker_threads)
.field("max_blocking_threads", &self.max_blocking_threads)
.field(
"thread_name",
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | e14307393a3e04cc50b3a04a019b589a2d409d3f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14307393a3e04cc50b3a04a019b589a2d409d3f/tokio/src/runtime/builder.rs | 1,041 | 1,057 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:22 | ///
/// This option is intended to make certain parts of the runtime
/// deterministic (e.g. the [`tokio::select!`] macro). In the case of
/// [`tokio::select!`] it will ensure that the order that branches are
/// polled is deterministic.
///
/// In addition to the code s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 26791a62bce6287e3a7274a726e690f98a29a34b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/26791a62bce6287e3a7274a726e690f98a29a34b/tokio/src/runtime/builder.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:23 | let blocking_spawner = blocking_pool.spawner().clone();
// Generate a rng seed for this runtime.
let seed_generator_1 = self.seed_generator.next_generator();
let seed_generator_2 = self.seed_generator.next_generator();
// And now put a single-threaded scheduler on top of the timer. Whe... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 26791a62bce6287e3a7274a726e690f98a29a34b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/26791a62bce6287e3a7274a726e690f98a29a34b/tokio/src/runtime/builder.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:25 | self.enable_time = true;
self
}
}
}
cfg_test_util! {
impl Builder {
/// Controls if the runtime's clock starts paused or advancing.
///
/// Pausing time requires the current-thread runtime; construction of
/// the runtime will panic otherwise.
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 26791a62bce6287e3a7274a726e690f98a29a34b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/26791a62bce6287e3a7274a726e690f98a29a34b/tokio/src/runtime/builder.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:26 | let (driver, driver_handle) = driver::Driver::new(self.get_cfg())?;
// Create the blocking pool
let blocking_pool =
blocking::create_blocking_pool(self, self.max_blocking_threads + core_threads);
let blocking_spawner = blocking_pool.spawner().clone();
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 26791a62bce6287e3a7274a726e690f98a29a34b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/26791a62bce6287e3a7274a726e690f98a29a34b/tokio/src/runtime/builder.rs | 1,001 | 1,058 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:22 | ///
/// This option is intended to make certain parts of the runtime
/// deterministic (e.g. the [`tokio::select!`] macro). In the case of
/// [`tokio::select!`] it will ensure that the order that branches are
/// polled is deterministic.
///
/// In addition to the code s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df99428c17ff03134d8f081ee80ef0f6fbe3c813 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df99428c17ff03134d8f081ee80ef0f6fbe3c813/tokio/src/runtime/builder.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:23 | let blocking_spawner = blocking_pool.spawner().clone();
// Generate a rng seed for this runtime.
let seed_generator_1 = self.seed_generator.next_generator();
let seed_generator_2 = self.seed_generator.next_generator();
// And now put a single-threaded scheduler on top of the timer. Whe... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df99428c17ff03134d8f081ee80ef0f6fbe3c813 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df99428c17ff03134d8f081ee80ef0f6fbe3c813/tokio/src/runtime/builder.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:24 | ///
/// Doing this enables using net, process, signal, and some I/O types on
/// the runtime.
///
/// # Examples
///
/// ```
/// use tokio::runtime;
///
/// let rt = runtime::Builder::new_multi_thread()
/// .enable_io()
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df99428c17ff03134d8f081ee80ef0f6fbe3c813 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df99428c17ff03134d8f081ee80ef0f6fbe3c813/tokio/src/runtime/builder.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:25 | }
}
}
cfg_test_util! {
impl Builder {
/// Controls if the runtime's clock starts paused or advancing.
///
/// Pausing time requires the current-thread runtime; construction of
/// the runtime will panic otherwise.
///
/// # Examples
///
/// ```
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df99428c17ff03134d8f081ee80ef0f6fbe3c813 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df99428c17ff03134d8f081ee80ef0f6fbe3c813/tokio/src/runtime/builder.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:26 | // Create the blocking pool
let blocking_pool =
blocking::create_blocking_pool(self, self.max_blocking_threads + core_threads);
let blocking_spawner = blocking_pool.spawner().clone();
// Generate a rng seed for this runtime.
let seed_generator_1 = self.se... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df99428c17ff03134d8f081ee80ef0f6fbe3c813 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df99428c17ff03134d8f081ee80ef0f6fbe3c813/tokio/src/runtime/builder.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:27 | }
}
impl fmt::Debug for Builder {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Builder")
.field("worker_threads", &self.worker_threads)
.field("max_blocking_threads", &self.max_blocking_threads)
.field(
"thread_name",
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df99428c17ff03134d8f081ee80ef0f6fbe3c813 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df99428c17ff03134d8f081ee80ef0f6fbe3c813/tokio/src/runtime/builder.rs | 1,041 | 1,060 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:1 | use crate::runtime::handle::Handle;
use crate::runtime::{blocking, driver, Callback, Runtime};
use crate::util::{RngSeed, RngSeedGenerator};
use std::fmt;
use std::io;
use std::time::Duration;
/// Builds Tokio Runtime with custom configuration values.
///
/// Methods can be chained in order to set the configuration v... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 121f839b4b6e0c2f3ac213dfd3c89796914b14ef | github | async-runtime | https://github.com/tokio-rs/tokio/blob/121f839b4b6e0c2f3ac213dfd3c89796914b14ef/tokio/src/runtime/builder.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:22 | ///
/// This option is intended to make certain parts of the runtime deterministic.
/// Specifically, it affects the [`tokio::select!`] macro and the work stealing
/// algorithm. In the case of [`tokio::select!`] it will ensure that the order that
/// branches are polled is deterministic... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 2f244514346a37bf598d8fc1c593d68771eb6047 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2f244514346a37bf598d8fc1c593d68771eb6047/tokio/src/runtime/builder.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:23 | // Blocking pool
let blocking_pool = blocking::create_blocking_pool(self, self.max_blocking_threads);
let blocking_spawner = blocking_pool.spawner().clone();
// Generate a rng seed for this runtime.
let seed_generator_1 = self.seed_generator.next_generator();
let seed_generator_... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 2f244514346a37bf598d8fc1c593d68771eb6047 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2f244514346a37bf598d8fc1c593d68771eb6047/tokio/src/runtime/builder.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:24 | cfg_io_driver! {
impl Builder {
/// Enables the I/O driver.
///
/// Doing this enables using net, process, signal, and some I/O types on
/// the runtime.
///
/// # Examples
///
/// ```
/// use tokio::runtime;
///
/// let rt = ru... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 2f244514346a37bf598d8fc1c593d68771eb6047 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2f244514346a37bf598d8fc1c593d68771eb6047/tokio/src/runtime/builder.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:25 | pub fn enable_time(&mut self) -> &mut Self {
self.enable_time = true;
self
}
}
}
cfg_test_util! {
impl Builder {
/// Controls if the runtime's clock starts paused or advancing.
///
/// Pausing time requires the current-thread runtime; construction of
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 2f244514346a37bf598d8fc1c593d68771eb6047 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2f244514346a37bf598d8fc1c593d68771eb6047/tokio/src/runtime/builder.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:26 | let (driver, driver_handle) = driver::Driver::new(self.get_cfg())?;
// Create the blocking pool
let blocking_pool =
blocking::create_blocking_pool(self, self.max_blocking_threads + core_threads);
let blocking_spawner = blocking_pool.spawner().clone();
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 2f244514346a37bf598d8fc1c593d68771eb6047 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2f244514346a37bf598d8fc1c593d68771eb6047/tokio/src/runtime/builder.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:27 | blocking_pool,
})
}
}
}
impl fmt::Debug for Builder {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Builder")
.field("worker_threads", &self.worker_threads)
.field("max_blocking_threads", &self.max_blocking_threads)
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 2f244514346a37bf598d8fc1c593d68771eb6047 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2f244514346a37bf598d8fc1c593d68771eb6047/tokio/src/runtime/builder.rs | 1,041 | 1,063 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:26 | let (driver, driver_handle) = driver::Driver::new(self.get_cfg())?;
// Create the blocking pool
let blocking_pool =
blocking::create_blocking_pool(self, self.max_blocking_threads + core_threads);
let blocking_spawner = blocking_pool.spawner().clone();
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | cdd6eeaf70351220df05126a7f0c353b0058dc95 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cdd6eeaf70351220df05126a7f0c353b0058dc95/tokio/src/runtime/builder.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:25 | pub fn enable_time(&mut self) -> &mut Self {
self.enable_time = true;
self
}
}
}
cfg_test_util! {
impl Builder {
/// Controls if the runtime's clock starts paused or advancing.
///
/// Pausing time requires the current-thread runtime; construction of
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/tokio/src/runtime/builder.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:26 | let core_threads = self.worker_threads.unwrap_or_else(num_cpus);
let (driver, driver_handle) = driver::Driver::new(self.get_cfg())?;
// Create the blocking pool
let blocking_pool =
blocking::create_blocking_pool(self, self.max_blocking_threads + core_threads);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/tokio/src/runtime/builder.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:27 | scheduler: Scheduler::MultiThread(scheduler),
handle,
blocking_pool,
})
}
}
}
impl fmt::Debug for Builder {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Builder")
.field("worker_threads", &self.worker_thre... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 2effa7ff8a01c5890eb5273d30f8bb6ddb571d14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2effa7ff8a01c5890eb5273d30f8bb6ddb571d14/tokio/src/runtime/builder.rs | 1,041 | 1,065 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:22 | ///
/// This option is intended to make certain parts of the runtime deterministic.
/// Specifically, it affects the [`tokio::select!`] macro and the work stealing
/// algorithm. In the case of [`tokio::select!`] it will ensure that the order that
/// branches are polled is deterministic... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/builder.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:23 | let (driver, driver_handle) = driver::Driver::new(self.get_cfg())?;
// Blocking pool
let blocking_pool = blocking::create_blocking_pool(self, self.max_blocking_threads);
let blocking_spawner = blocking_pool.spawner().clone();
// And now put a single-threaded scheduler on top of the tim... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/builder.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:25 | self.enable_time = true;
self
}
}
}
cfg_test_util! {
impl Builder {
/// Controls if the runtime's clock starts paused or advancing.
///
/// Pausing time requires the current-thread runtime; construction of
/// the runtime will panic otherwise.
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/builder.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:26 | let (driver, driver_handle) = driver::Driver::new(self.get_cfg())?;
// Create the blocking pool
let blocking_pool =
blocking::create_blocking_pool(self, self.max_blocking_threads + core_threads);
let blocking_spawner = blocking_pool.spawner().clone();
le... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/builder.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:27 | handle,
blocking_pool,
})
}
}
}
impl fmt::Debug for Builder {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Builder")
.field("worker_threads", &self.worker_threads)
.field("max_blocking_threads", &self.max_bloc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | ebeb78ed40027032feb77c89a1de4b58d2dcafbf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ebeb78ed40027032feb77c89a1de4b58d2dcafbf/tokio/src/runtime/builder.rs | 1,041 | 1,064 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:1 | use crate::runtime::handle::Handle;
use crate::runtime::{blocking, driver, Callback, Runtime, Spawner};
use crate::util::{RngSeed, RngSeedGenerator};
use std::fmt;
use std::io;
use std::time::Duration;
/// Builds Tokio Runtime with custom configuration values.
///
/// Methods can be chained in order to set the config... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b5709baa917494043e21589adb10347c57361f1f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b5709baa917494043e21589adb10347c57361f1f/tokio/src/runtime/builder.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:22 | ///
/// This option is intended to make certain parts of the runtime deterministic.
/// Specifically, it affects the [`tokio::select!`] macro and the work stealing
/// algorithm. In the case of [`tokio::select!`] it will ensure that the order that
/// branches are polled is deterministic... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b5709baa917494043e21589adb10347c57361f1f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b5709baa917494043e21589adb10347c57361f1f/tokio/src/runtime/builder.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:23 | // Blocking pool
let blocking_pool = blocking::create_blocking_pool(self, self.max_blocking_threads);
let blocking_spawner = blocking_pool.spawner().clone();
// And now put a single-threaded scheduler on top of the timer. When
// there are no futures ready to do something, it'll let the... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b5709baa917494043e21589adb10347c57361f1f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b5709baa917494043e21589adb10347c57361f1f/tokio/src/runtime/builder.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:25 | self.enable_time = true;
self
}
}
}
cfg_test_util! {
impl Builder {
/// Controls if the runtime's clock starts paused or advancing.
///
/// Pausing time requires the current-thread runtime; construction of
/// the runtime will panic otherwise.
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b5709baa917494043e21589adb10347c57361f1f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b5709baa917494043e21589adb10347c57361f1f/tokio/src/runtime/builder.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:26 | let (driver, driver_handle) = driver::Driver::new(self.get_cfg())?;
// Create the blocking pool
let blocking_pool =
blocking::create_blocking_pool(self, self.max_blocking_threads + core_threads);
let blocking_spawner = blocking_pool.spawner().clone();
le... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b5709baa917494043e21589adb10347c57361f1f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b5709baa917494043e21589adb10347c57361f1f/tokio/src/runtime/builder.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:2 | /// Runtime type
kind: Kind,
/// Whether or not to enable the I/O driver
enable_io: bool,
/// Whether or not to enable the time driver
enable_time: bool,
/// Whether or not the clock should start paused.
start_paused: bool,
/// The number of worker threads, used by Runtime.
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 9e0275977981356fc5618b2061cdac8eb39a9569 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9e0275977981356fc5618b2061cdac8eb39a9569/tokio/src/runtime/builder.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:5 | /// rt.spawn(async { panic!("boom"); });
/// rt.spawn(async {
/// // This task never completes.
/// });
///
/// rt.block_on(async {
/// // Do some work
/// # loop { tokio::task::yield_now().await; }
/// })
/// # }
/// ```
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 9e0275977981356fc5618b2061cdac8eb39a9569 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9e0275977981356fc5618b2061cdac8eb39a9569/tokio/src/runtime/builder.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:6 | Builder::new(Kind::CurrentThread, 31, EVENT_INTERVAL)
}
cfg_not_wasi! {
/// Returns a new builder with the multi thread scheduler selected.
///
/// Configuration methods can be chained on the return value.
#[cfg(feature = "rt-multi-thread")]
#[cfg_attr(docsrs, doc(cfg(fe... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 9e0275977981356fc5618b2061cdac8eb39a9569 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9e0275977981356fc5618b2061cdac8eb39a9569/tokio/src/runtime/builder.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:7 | // Do not set a stack size by default
thread_stack_size: None,
// No worker thread callbacks
after_start: None,
before_stop: None,
before_park: None,
after_unpark: None,
keep_alive: None,
// Defaults for these values depe... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 9e0275977981356fc5618b2061cdac8eb39a9569 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9e0275977981356fc5618b2061cdac8eb39a9569/tokio/src/runtime/builder.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:10 | /// In old versions `max_threads` limited both blocking and worker threads, but the
/// current `max_blocking_threads` does not include async worker threads in the count.
///
/// [`spawn_blocking`]: fn@crate::task::spawn_blocking
/// [`worker_threads`]: Self::worker_threads
/// [`thread_keep_alive`]... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 9e0275977981356fc5618b2061cdac8eb39a9569 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9e0275977981356fc5618b2061cdac8eb39a9569/tokio/src/runtime/builder.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:12 | /// ```
pub fn thread_stack_size(&mut self, val: usize) -> &mut Self {
self.thread_stack_size = Some(val);
self
}
/// Executes function `f` after each thread is started but before it starts
/// doing work.
///
/// This is intended for bookkeeping and monitoring use cases.
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 9e0275977981356fc5618b2061cdac8eb39a9569 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9e0275977981356fc5618b2061cdac8eb39a9569/tokio/src/runtime/builder.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:15 | ///
/// runtime.block_on(async {
/// barrier.wait().await;
/// })
/// # }
/// ```
#[cfg(not(loom))]
pub fn on_thread_park<F>(&mut self, f: F) -> &mut Self
where
F: Fn() + Send + Sync + 'static,
{
self.before_park = Some(std::sync::Arc::new(f));
self
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 9e0275977981356fc5618b2061cdac8eb39a9569 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9e0275977981356fc5618b2061cdac8eb39a9569/tokio/src/runtime/builder.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:16 | /// ```
#[cfg(not(loom))]
pub fn on_thread_unpark<F>(&mut self, f: F) -> &mut Self
where
F: Fn() + Send + Sync + 'static,
{
self.after_unpark = Some(std::sync::Arc::new(f));
self
}
/// Creates the configured `Runtime`.
///
/// The returned `Runtime` instance is r... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 9e0275977981356fc5618b2061cdac8eb39a9569 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9e0275977981356fc5618b2061cdac8eb39a9569/tokio/src/runtime/builder.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:21 | /// throughput when tasks tend to have longer poll times.
///
/// This configuration option will disable this heuristic resulting in
/// all scheduled tasks being pushed into the worker-local queue, which
/// is stealable.
///
/// Consider trying this option when the task... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 9e0275977981356fc5618b2061cdac8eb39a9569 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9e0275977981356fc5618b2061cdac8eb39a9569/tokio/src/runtime/builder.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:22 | let blocking_pool = blocking::create_blocking_pool(self, self.max_blocking_threads);
let blocking_spawner = blocking_pool.spawner().clone();
// And now put a single-threaded scheduler on top of the timer. When
// there are no futures ready to do something, it'll let the timer or
// the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 9e0275977981356fc5618b2061cdac8eb39a9569 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9e0275977981356fc5618b2061cdac8eb39a9569/tokio/src/runtime/builder.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:23 | /// the runtime.
///
/// # Examples
///
/// ```
/// use tokio::runtime;
///
/// let rt = runtime::Builder::new_multi_thread()
/// .enable_io()
/// .build()
/// .unwrap();
/// ```
pub fn enable_io(&mut self) -> &m... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 9e0275977981356fc5618b2061cdac8eb39a9569 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9e0275977981356fc5618b2061cdac8eb39a9569/tokio/src/runtime/builder.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:24 | }
cfg_test_util! {
impl Builder {
/// Controls if the runtime's clock starts paused or advancing.
///
/// Pausing time requires the current-thread runtime; construction of
/// the runtime will panic otherwise.
///
/// # Examples
///
/// ```
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 9e0275977981356fc5618b2061cdac8eb39a9569 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9e0275977981356fc5618b2061cdac8eb39a9569/tokio/src/runtime/builder.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:25 | blocking::create_blocking_pool(self, self.max_blocking_threads + core_threads);
let blocking_spawner = blocking_pool.spawner().clone();
let (scheduler, launch) = MultiThread::new(
core_threads,
driver,
Config {
before_park: sel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 9e0275977981356fc5618b2061cdac8eb39a9569 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9e0275977981356fc5618b2061cdac8eb39a9569/tokio/src/runtime/builder.rs | 961 | 1,017 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:21 | /// throughput when tasks tend to have longer poll times.
///
/// This configuration option will disable this heuristic resulting in
/// all scheduled tasks being pushed into the worker-local queue, which
/// is stealable.
///
/// Consider trying this option when the task... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 198e2d8e794c62e1f1d5581e0cc13ff524570191 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/198e2d8e794c62e1f1d5581e0cc13ff524570191/tokio/src/runtime/builder.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:22 | let blocking_pool = blocking::create_blocking_pool(self, self.max_blocking_threads);
let blocking_spawner = blocking_pool.spawner().clone();
// And now put a single-threaded scheduler on top of the timer. When
// there are no futures ready to do something, it'll let the timer or
// the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 198e2d8e794c62e1f1d5581e0cc13ff524570191 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/198e2d8e794c62e1f1d5581e0cc13ff524570191/tokio/src/runtime/builder.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:23 | /// Enables the I/O driver.
///
/// Doing this enables using net, process, signal, and some I/O types on
/// the runtime.
///
/// # Examples
///
/// ```
/// use tokio::runtime;
///
/// let rt = runtime::Builder::new_multi_thread()
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 198e2d8e794c62e1f1d5581e0cc13ff524570191 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/198e2d8e794c62e1f1d5581e0cc13ff524570191/tokio/src/runtime/builder.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:24 | self
}
}
}
cfg_test_util! {
impl Builder {
/// Controls if the runtime's clock starts paused or advancing.
///
/// Pausing time requires the current-thread runtime; construction of
/// the runtime will panic otherwise.
///
/// # Examples
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 198e2d8e794c62e1f1d5581e0cc13ff524570191 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/198e2d8e794c62e1f1d5581e0cc13ff524570191/tokio/src/runtime/builder.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:25 | // Create the blocking pool
let blocking_pool =
blocking::create_blocking_pool(self, self.max_blocking_threads + core_threads);
let blocking_spawner = blocking_pool.spawner().clone();
let (scheduler, launch) = MultiThread::new(
core_threads,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 198e2d8e794c62e1f1d5581e0cc13ff524570191 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/198e2d8e794c62e1f1d5581e0cc13ff524570191/tokio/src/runtime/builder.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:21 | /// throughput when tasks tend to have longer poll times.
///
/// This configuration option will disable this heuristic resulting in
/// all scheduled tasks being pushed into the worker-local queue, which
/// is stealable.
///
/// Consider trying this option when the task... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 56ffea09e5ab682e49eab0374da651f277e72566 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/56ffea09e5ab682e49eab0374da651f277e72566/tokio/src/runtime/builder.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:22 | let blocking_pool = blocking::create_blocking_pool(self, self.max_blocking_threads);
let blocking_spawner = blocking_pool.spawner().clone();
// And now put a single-threaded scheduler on top of the timer. When
// there are no futures ready to do something, it'll let the timer or
// the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 56ffea09e5ab682e49eab0374da651f277e72566 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/56ffea09e5ab682e49eab0374da651f277e72566/tokio/src/runtime/builder.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:24 | self
}
}
}
cfg_test_util! {
impl Builder {
/// Controls if the runtime's clock starts paused or advancing.
///
/// Pausing time requires the current-thread runtime; construction of
/// the runtime will panic otherwise.
///
/// # Examples
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 56ffea09e5ab682e49eab0374da651f277e72566 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/56ffea09e5ab682e49eab0374da651f277e72566/tokio/src/runtime/builder.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:25 | // Create the blocking pool
let blocking_pool =
blocking::create_blocking_pool(self, self.max_blocking_threads + core_threads);
let blocking_spawner = blocking_pool.spawner().clone();
let (scheduler, launch) = MultiThread::new(
core_threads,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 56ffea09e5ab682e49eab0374da651f277e72566 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/56ffea09e5ab682e49eab0374da651f277e72566/tokio/src/runtime/builder.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:21 | /// throughput when tasks tend to have longer poll times.
///
/// This configuration option will disable this heuristic resulting in
/// all scheduled tasks being pushed into the worker-local queue, which
/// is stealable.
///
/// Consider trying this option when the task... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | a3411a412c3424df7dcd151441fe0435c0a92c9c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/src/runtime/builder.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:22 | let blocking_spawner = blocking_pool.spawner().clone();
let handle_inner = HandleInner {
io_handle: resources.io_handle,
time_handle: resources.time_handle,
signal_handle: resources.signal_handle,
clock: resources.clock,
blocking_spawner,
};
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | a3411a412c3424df7dcd151441fe0435c0a92c9c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/src/runtime/builder.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:24 | }
}
}
cfg_test_util! {
impl Builder {
/// Controls if the runtime's clock starts paused or advancing.
///
/// Pausing time requires the current-thread runtime; construction of
/// the runtime will panic otherwise.
///
/// # Examples
///
/// ```
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | a3411a412c3424df7dcd151441fe0435c0a92c9c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/src/runtime/builder.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:25 | let blocking_pool =
blocking::create_blocking_pool(self, self.max_blocking_threads + core_threads);
let blocking_spawner = blocking_pool.spawner().clone();
let handle_inner = HandleInner {
io_handle: resources.io_handle,
time_handle: resources.tim... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | a3411a412c3424df7dcd151441fe0435c0a92c9c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/src/runtime/builder.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:26 | }
}
}
impl fmt::Debug for Builder {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Builder")
.field("worker_threads", &self.worker_threads)
.field("max_blocking_threads", &self.max_blocking_threads)
.field(
"thread_name... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | a3411a412c3424df7dcd151441fe0435c0a92c9c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/src/runtime/builder.rs | 1,001 | 1,021 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:16 | /// ```
#[cfg(not(loom))]
pub fn on_thread_unpark<F>(&mut self, f: F) -> &mut Self
where
F: Fn() + Send + Sync + 'static,
{
self.after_unpark = Some(std::sync::Arc::new(f));
self
}
/// Creates the configured `Runtime`.
///
/// The returned `Runtime` instance is r... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b023522a37a48d16de02e654b6c88ffe1eccb280 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b023522a37a48d16de02e654b6c88ffe1eccb280/tokio/src/runtime/builder.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:21 | /// throughput when tasks tend to have longer poll times.
///
/// This configuration option will disable this heuristic resulting in
/// all scheduled tasks being pushed into the worker-local queue, which
/// is stealable.
///
/// Consider trying this option when the task... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b023522a37a48d16de02e654b6c88ffe1eccb280 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b023522a37a48d16de02e654b6c88ffe1eccb280/tokio/src/runtime/builder.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:22 | let blocking_spawner = blocking_pool.spawner().clone();
let handle_inner = HandleInner {
io_handle: resources.io_handle,
time_handle: resources.time_handle,
signal_handle: resources.signal_handle,
clock: resources.clock,
blocking_spawner,
};
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b023522a37a48d16de02e654b6c88ffe1eccb280 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b023522a37a48d16de02e654b6c88ffe1eccb280/tokio/src/runtime/builder.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:24 | }
}
}
cfg_test_util! {
impl Builder {
/// Controls if the runtime's clock starts paused or advancing.
///
/// Pausing time requires the current-thread runtime; construction of
/// the runtime will panic otherwise.
///
/// # Examples
///
/// ```
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b023522a37a48d16de02e654b6c88ffe1eccb280 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b023522a37a48d16de02e654b6c88ffe1eccb280/tokio/src/runtime/builder.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:25 | let blocking_pool =
blocking::create_blocking_pool(self, self.max_blocking_threads + core_threads);
let blocking_spawner = blocking_pool.spawner().clone();
let handle_inner = HandleInner {
io_handle: resources.io_handle,
time_handle: resources.tim... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b023522a37a48d16de02e654b6c88ffe1eccb280 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b023522a37a48d16de02e654b6c88ffe1eccb280/tokio/src/runtime/builder.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:2 | /// Runtime type
kind: Kind,
/// Whether or not to enable the I/O driver
enable_io: bool,
/// Whether or not to enable the time driver
enable_time: bool,
/// Whether or not the clock should start paused.
start_paused: bool,
/// The number of worker threads, used by Runtime.
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df28ac092f0464d9c00eeb7f58e3b85dcb5bce52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df28ac092f0464d9c00eeb7f58e3b85dcb5bce52/tokio/src/runtime/builder.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:5 | /// rt.block_on(async {
/// // Do some work
/// # loop { tokio::task::yield_now().await; }
/// })
/// # }
/// ```
///
/// [`JoinHandle`]: struct@crate::task::JoinHandle
ShutdownRuntime,
}
}
pub(crate) type ThreadNameFn = std::sync::Arc<dyn Fn() ->... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df28ac092f0464d9c00eeb7f58e3b85dcb5bce52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df28ac092f0464d9c00eeb7f58e3b85dcb5bce52/tokio/src/runtime/builder.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:6 | /// Returns a new builder with the multi thread scheduler selected.
///
/// Configuration methods can be chained on the return value.
#[cfg(feature = "rt-multi-thread")]
#[cfg_attr(docsrs, doc(cfg(feature = "rt-multi-thread")))]
pub fn new_multi_thread() -> Builder {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df28ac092f0464d9c00eeb7f58e3b85dcb5bce52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df28ac092f0464d9c00eeb7f58e3b85dcb5bce52/tokio/src/runtime/builder.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:7 | after_start: None,
before_stop: None,
before_park: None,
after_unpark: None,
keep_alive: None,
// Defaults for these values depend on the scheduler kind, so we get them
// as parameters.
global_queue_interval,
event_interv... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df28ac092f0464d9c00eeb7f58e3b85dcb5bce52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df28ac092f0464d9c00eeb7f58e3b85dcb5bce52/tokio/src/runtime/builder.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:10 | #[cfg_attr(docsrs, doc(alias = "max_threads"))]
pub fn max_blocking_threads(&mut self, val: usize) -> &mut Self {
assert!(val > 0, "Max blocking threads cannot be set to 0");
self.max_blocking_threads = val;
self
}
/// Sets name of threads spawned by the `Runtime`'s thread pool.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df28ac092f0464d9c00eeb7f58e3b85dcb5bce52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df28ac092f0464d9c00eeb7f58e3b85dcb5bce52/tokio/src/runtime/builder.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:11 | /// static ATOMIC_ID: AtomicUsize = AtomicUsize::new(0);
/// let id = ATOMIC_ID.fetch_add(1, Ordering::SeqCst);
/// format!("my-pool-{}", id)
/// })
/// .build();
/// # }
/// ```
pub fn thread_name_fn<F>(&mut self, f: F) -> &mut Self
where
F: Fn() -> ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df28ac092f0464d9c00eeb7f58e3b85dcb5bce52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df28ac092f0464d9c00eeb7f58e3b85dcb5bce52/tokio/src/runtime/builder.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:12 | /// doing work.
///
/// This is intended for bookkeeping and monitoring use cases.
///
/// # Examples
///
/// ```
/// # use tokio::runtime;
/// # pub fn main() {
/// let runtime = runtime::Builder::new_multi_thread()
/// .on_thread_start(|| {
/// println!("thread ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df28ac092f0464d9c00eeb7f58e3b85dcb5bce52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df28ac092f0464d9c00eeb7f58e3b85dcb5bce52/tokio/src/runtime/builder.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:15 | pub fn on_thread_park<F>(&mut self, f: F) -> &mut Self
where
F: Fn() + Send + Sync + 'static,
{
self.before_park = Some(std::sync::Arc::new(f));
self
}
/// Executes function `f` just after a thread unparks (starts executing tasks).
///
/// This is intended for bookkeepin... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df28ac092f0464d9c00eeb7f58e3b85dcb5bce52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df28ac092f0464d9c00eeb7f58e3b85dcb5bce52/tokio/src/runtime/builder.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:16 | self
}
/// Creates the configured `Runtime`.
///
/// The returned `Runtime` instance is ready to spawn tasks.
///
/// # Examples
///
/// ```
/// use tokio::runtime::Builder;
///
/// let rt = Builder::new_multi_thread().build().unwrap();
///
/// rt.block_on(async {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df28ac092f0464d9c00eeb7f58e3b85dcb5bce52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df28ac092f0464d9c00eeb7f58e3b85dcb5bce52/tokio/src/runtime/builder.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:20 | /// # pub fn main() {
/// let rt = runtime::Builder::new_current_thread()
/// .unhandled_panic(UnhandledPanic::ShutdownRuntime)
/// .build()
/// .unwrap();
///
/// rt.spawn(async { panic!("boom"); });
/// rt.spawn(async {
/// // This task n... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df28ac092f0464d9c00eeb7f58e3b85dcb5bce52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df28ac092f0464d9c00eeb7f58e3b85dcb5bce52/tokio/src/runtime/builder.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:21 | };
// And now put a single-threaded scheduler on top of the timer. When
// there are no futures ready to do something, it'll let the timer or
// the reactor to generate some new stimuli for the futures to continue
// in their life.
let scheduler = BasicScheduler::new(
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df28ac092f0464d9c00eeb7f58e3b85dcb5bce52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df28ac092f0464d9c00eeb7f58e3b85dcb5bce52/tokio/src/runtime/builder.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:22 | /// let rt = runtime::Builder::new_multi_thread()
/// .enable_io()
/// .build()
/// .unwrap();
/// ```
pub fn enable_io(&mut self) -> &mut Self {
self.enable_io = true;
self
}
}
}
cfg_time! {
impl Builder {
/// Enables ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df28ac092f0464d9c00eeb7f58e3b85dcb5bce52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df28ac092f0464d9c00eeb7f58e3b85dcb5bce52/tokio/src/runtime/builder.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:23 | /// the runtime will panic otherwise.
///
/// # Examples
///
/// ```
/// use tokio::runtime;
///
/// let rt = runtime::Builder::new_current_thread()
/// .enable_time()
/// .start_paused(true)
/// .build()
/// .unwrap... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df28ac092f0464d9c00eeb7f58e3b85dcb5bce52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df28ac092f0464d9c00eeb7f58e3b85dcb5bce52/tokio/src/runtime/builder.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:24 | blocking_spawner,
};
let (scheduler, launch) = ThreadPool::new(
core_threads,
driver,
handle_inner,
Config {
before_park: self.before_park.clone(),
after_unpark: self.after_unpark.clone(),
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df28ac092f0464d9c00eeb7f58e3b85dcb5bce52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df28ac092f0464d9c00eeb7f58e3b85dcb5bce52/tokio/src/runtime/builder.rs | 921 | 971 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:25 | "thread_name",
&"<dyn Fn() -> String + Send + Sync + 'static>",
)
.field("thread_stack_size", &self.thread_stack_size)
.field("after_start", &self.after_start.as_ref().map(|_| "..."))
.field("before_stop", &self.before_stop.as_ref().map(|_| "..."))
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | df28ac092f0464d9c00eeb7f58e3b85dcb5bce52 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df28ac092f0464d9c00eeb7f58e3b85dcb5bce52/tokio/src/runtime/builder.rs | 961 | 971 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:20 | /// # pub fn main() {
/// let rt = runtime::Builder::new_current_thread()
/// .unhandled_panic(UnhandledPanic::ShutdownRuntime)
/// .build()
/// .unwrap();
///
/// rt.spawn(async { panic!("boom"); });
/// rt.spawn(async {
/// // This task n... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/src/runtime/builder.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:21 | blocking_spawner,
};
// And now put a single-threaded scheduler on top of the timer. When
// there are no futures ready to do something, it'll let the timer or
// the reactor to generate some new stimuli for the futures to continue
// in their life.
let scheduler = Basic... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/src/runtime/builder.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:22 | ///
/// let rt = runtime::Builder::new_multi_thread()
/// .enable_io()
/// .build()
/// .unwrap();
/// ```
pub fn enable_io(&mut self) -> &mut Self {
self.enable_io = true;
self
}
}
}
cfg_time! {
impl Builder {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/src/runtime/builder.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:23 | /// Pausing time requires the current-thread runtime; construction of
/// the runtime will panic otherwise.
///
/// # Examples
///
/// ```
/// use tokio::runtime;
///
/// let rt = runtime::Builder::new_current_thread()
/// .enable_time()
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/src/runtime/builder.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:24 | clock: resources.clock,
blocking_spawner,
};
let (scheduler, launch) = ThreadPool::new(
core_threads,
driver,
handle_inner,
self.before_park.clone(),
self.after_unpark.clone(),
self.g... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/src/runtime/builder.rs | 921 | 968 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:5 | /// rt.block_on(async {
/// // Do some work
/// # loop { tokio::task::yield_now().await; }
/// })
/// # }
/// ```
///
/// [`JoinHandle`]: struct@crate::task::JoinHandle
ShutdownRuntime,
}
}
pub(crate) type ThreadNameFn = std::sync::Arc<dyn Fn() ->... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | f3e340a35b306e926e78537a0dd65b2e9b9cdc89 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/src/runtime/builder.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:16 | self
}
/// Creates the configured `Runtime`.
///
/// The returned `Runtime` instance is ready to spawn tasks.
///
/// # Examples
///
/// ```
/// use tokio::runtime::Builder;
///
/// let rt = Builder::new_multi_thread().build().unwrap();
///
/// rt.block_on(async {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | f3e340a35b306e926e78537a0dd65b2e9b9cdc89 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/src/runtime/builder.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:7 | after_start: None,
before_stop: None,
before_park: None,
after_unpark: None,
keep_alive: None,
// Defaults for these values depend on the scheduler kind, so we get them
// as parameters.
global_queue_interval,
event_interv... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 1578575db8d0bc7838f7ea2ddbe7194ac2f4aa87 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1578575db8d0bc7838f7ea2ddbe7194ac2f4aa87/tokio/src/runtime/builder.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:10 | /// [`spawn_blocking`]: fn@crate::task::spawn_blocking
/// [`worker_threads`]: Self::worker_threads
/// [`thread_keep_alive`]: Self::thread_keep_alive
#[track_caller]
#[cfg_attr(docsrs, doc(alias = "max_threads"))]
pub fn max_blocking_threads(&mut self, val: usize) -> &mut Self {
assert!(val... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 1578575db8d0bc7838f7ea2ddbe7194ac2f4aa87 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1578575db8d0bc7838f7ea2ddbe7194ac2f4aa87/tokio/src/runtime/builder.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:15 | /// })
/// # }
/// ```
#[cfg(not(loom))]
pub fn on_thread_park<F>(&mut self, f: F) -> &mut Self
where
F: Fn() + Send + Sync + 'static,
{
self.before_park = Some(std::sync::Arc::new(f));
self
}
/// Executes function `f` just after a thread unparks (starts executin... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 1578575db8d0bc7838f7ea2ddbe7194ac2f4aa87 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1578575db8d0bc7838f7ea2ddbe7194ac2f4aa87/tokio/src/runtime/builder.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:16 | where
F: Fn() + Send + Sync + 'static,
{
self.after_unpark = Some(std::sync::Arc::new(f));
self
}
/// Creates the configured `Runtime`.
///
/// The returned `Runtime` instance is ready to spawn tasks.
///
/// # Examples
///
/// ```
/// use tokio::runtime:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 1578575db8d0bc7838f7ea2ddbe7194ac2f4aa87 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1578575db8d0bc7838f7ea2ddbe7194ac2f4aa87/tokio/src/runtime/builder.rs | 601 | 660 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.