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:20 | ///
/// ```should_panic
/// use tokio::runtime::{self, UnhandledPanic};
///
/// # pub fn main() {
/// let rt = runtime::Builder::new_current_thread()
/// .unhandled_panic(UnhandledPanic::ShutdownRuntime)
/// .build()
/// .unwrap();
///
... | 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 | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:21 | io_handle: resources.io_handle,
time_handle: resources.time_handle,
signal_handle: resources.signal_handle,
clock: resources.clock,
blocking_spawner,
};
// And now put a single-threaded scheduler on top of the timer. When
// there are no futures r... | 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 | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:22 | /// # Examples
///
/// ```
/// use tokio::runtime;
///
/// let rt = runtime::Builder::new_multi_thread()
/// .enable_io()
/// .build()
/// .unwrap();
/// ```
pub fn enable_io(&mut self) -> &mut Self {
self.enable_io ... | 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 | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:23 | 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
///
/// ```
/// u... | 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 | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:24 | let handle_inner = HandleInner {
io_handle: resources.io_handle,
time_handle: resources.time_handle,
signal_handle: resources.signal_handle,
clock: resources.clock,
blocking_spawner,
};
let (scheduler, launch) = Thr... | 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 | 921 | 972 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:25 | .field(
"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()... | 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 | 961 | 972 |
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 | 6d3f92dddc510e9276191cfab1b0432ce8248589 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/src/runtime/builder.rs | 241 | 300 |
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 | 159508b916038217ceb668d727d9618b567ea8b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159508b916038217ceb668d727d9618b567ea8b1/tokio/src/runtime/builder.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:6 | ///
/// 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 {
// The number `61` is fairly arbitrary. I believe this value was copied from golang.
Bui... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 159508b916038217ceb668d727d9618b567ea8b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159508b916038217ceb668d727d9618b567ea8b1/tokio/src/runtime/builder.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:7 | 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_interval,
#[cfg(tokio_unstable)]
unhandled_... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 159508b916038217ceb668d727d9618b567ea8b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159508b916038217ceb668d727d9618b567ea8b1/tokio/src/runtime/builder.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:15 | 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 bookkeeping and monitoring use cases; note that work
/// in this callback will ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 159508b916038217ceb668d727d9618b567ea8b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159508b916038217ceb668d727d9618b567ea8b1/tokio/src/runtime/builder.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:16 | /// 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 {
/// print... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 159508b916038217ceb668d727d9618b567ea8b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159508b916038217ceb668d727d9618b567ea8b1/tokio/src/runtime/builder.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:20 | /// .unhandled_panic(UnhandledPanic::ShutdownRuntime)
/// .build()
/// .unwrap();
///
/// rt.spawn(async { panic!("boom"); });
/// rt.spawn(async {
/// // This task never completes.
/// });
///
/// rt.block_on(async {
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 159508b916038217ceb668d727d9618b567ea8b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159508b916038217ceb668d727d9618b567ea8b1/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(
driver,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 159508b916038217ceb668d727d9618b567ea8b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159508b916038217ceb668d727d9618b567ea8b1/tokio/src/runtime/builder.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:22 | /// .enable_io()
/// .build()
/// .unwrap();
/// ```
pub fn enable_io(&mut self) -> &mut Self {
self.enable_io = true;
self
}
}
}
cfg_time! {
impl Builder {
/// Enables the time driver.
///
/// Doing this enable... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 159508b916038217ceb668d727d9618b567ea8b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159508b916038217ceb668d727d9618b567ea8b1/tokio/src/runtime/builder.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:23 | ///
/// # Examples
///
/// ```
/// use tokio::runtime;
///
/// let rt = runtime::Builder::new_current_thread()
/// .enable_time()
/// .start_paused(true)
/// .build()
/// .unwrap();
/// ```
pub fn start_pause... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 159508b916038217ceb668d727d9618b567ea8b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159508b916038217ceb668d727d9618b567ea8b1/tokio/src/runtime/builder.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:24 | };
let (scheduler, launch) = ThreadPool::new(
core_threads,
driver,
handle_inner,
self.before_park.clone(),
self.after_unpark.clone(),
self.global_queue_interval,
self.event_interval,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 159508b916038217ceb668d727d9618b567ea8b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/159508b916038217ceb668d727d9618b567ea8b1/tokio/src/runtime/builder.rs | 921 | 966 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:7 | 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_interval,
#[cfg(tokio_unstable)]
unhandled_... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | c98be229ff3a4e1e230711844b7e38a30cb64f2c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/runtime/builder.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:15 | 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 bookkeeping and monitoring use cases; note that work
/// in this callback will increase latencies when the application has all... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | c98be229ff3a4e1e230711844b7e38a30cb64f2c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/runtime/builder.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:16 | ///
/// 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 {
/// println!("Hello from the Tokio runtime");
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | c98be229ff3a4e1e230711844b7e38a30cb64f2c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/runtime/builder.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:20 | /// .unwrap();
///
/// 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 | c98be229ff3a4e1e230711844b7e38a30cb64f2c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/runtime/builder.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:21 | // 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(
driver,
handle_inner,
Config {
before_park: sel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | c98be229ff3a4e1e230711844b7e38a30cb64f2c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/runtime/builder.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:22 | /// .unwrap();
/// ```
pub fn enable_io(&mut self) -> &mut Self {
self.enable_io = true;
self
}
}
}
cfg_time! {
impl Builder {
/// Enables the time driver.
///
/// Doing this enables using `tokio::time` on the runtime.
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | c98be229ff3a4e1e230711844b7e38a30cb64f2c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/runtime/builder.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:23 | ///
/// ```
/// use tokio::runtime;
///
/// let rt = runtime::Builder::new_current_thread()
/// .enable_time()
/// .start_paused(true)
/// .build()
/// .unwrap();
/// ```
pub fn start_paused(&mut self, start_paused: bool) ->... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | c98be229ff3a4e1e230711844b7e38a30cb64f2c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/runtime/builder.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:24 | let (scheduler, launch) = ThreadPool::new(
core_threads,
driver,
handle_inner,
self.before_park.clone(),
self.after_unpark.clone(),
self.global_queue_interval,
self.event_interval,
);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | c98be229ff3a4e1e230711844b7e38a30cb64f2c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/runtime/builder.rs | 921 | 964 |
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 | f7a64538f7459e4dcdc05f6f944b6e553b1cef06 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f7a64538f7459e4dcdc05f6f944b6e553b1cef06/tokio/src/runtime/builder.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:3 | /// How many ticks before pulling a task from the global/remote queue?
pub(super) global_queue_interval: u32,
/// How many ticks before yielding to the driver for timer and I/O events?
pub(super) event_interval: u32,
}
pub(crate) type ThreadNameFn = std::sync::Arc<dyn Fn() -> String + Send + Sync + 'stati... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | f7a64538f7459e4dcdc05f6f944b6e553b1cef06 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f7a64538f7459e4dcdc05f6f944b6e553b1cef06/tokio/src/runtime/builder.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:4 | pub fn new_multi_thread() -> Builder {
// The number `61` is fairly arbitrary. I believe this value was copied from golang.
Builder::new(Kind::MultiThread, 61, 61)
}
/// Returns a new runtime builder initialized with default configuration
/// values.
///
/// Configuration methods ca... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | f7a64538f7459e4dcdc05f6f944b6e553b1cef06 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f7a64538f7459e4dcdc05f6f944b6e553b1cef06/tokio/src/runtime/builder.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:7 | ///
/// This will panic if `val` is not larger than `0`.
pub fn worker_threads(&mut self, val: usize) -> &mut Self {
assert!(val > 0, "Worker threads cannot be set to 0");
self.worker_threads = Some(val);
self
}
/// Specifies the limit for additional threads spawned by the Runti... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | f7a64538f7459e4dcdc05f6f944b6e553b1cef06 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f7a64538f7459e4dcdc05f6f944b6e553b1cef06/tokio/src/runtime/builder.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:13 | /// in this callback will increase latencies when the application has allowed one or
/// more runtime threads to go idle.
///
/// Note: There can only be one unpark callback for a runtime; calling this function
/// more than once replaces the last callback defined, rather than adding to it.
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | f7a64538f7459e4dcdc05f6f944b6e553b1cef06 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f7a64538f7459e4dcdc05f6f944b6e553b1cef06/tokio/src/runtime/builder.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:14 | ///
/// let rt = Builder::new_multi_thread().build().unwrap();
///
/// rt.block_on(async {
/// println!("Hello from the Tokio runtime");
/// });
/// ```
pub fn build(&mut self) -> io::Result<Runtime> {
match &self.kind {
Kind::CurrentThread => self.build_basic_runtim... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | f7a64538f7459e4dcdc05f6f944b6e553b1cef06 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f7a64538f7459e4dcdc05f6f944b6e553b1cef06/tokio/src/runtime/builder.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:16 | /// Sets the number of scheduler ticks after which the scheduler will poll for
/// external events (timers, I/O, and so on).
///
/// A scheduler "tick" roughly corresponds to one `poll` invocation on a task.
///
/// By default, the event interval is `61` for all scheduler types.
///
/// Sett... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | f7a64538f7459e4dcdc05f6f944b6e553b1cef06 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f7a64538f7459e4dcdc05f6f944b6e553b1cef06/tokio/src/runtime/builder.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:17 | let blocking_pool = blocking::create_blocking_pool(self, self.max_blocking_threads);
let blocking_spawner = blocking_pool.spawner().clone();
let handle_inner = HandleInner {
io_handle: resources.io_handle,
time_handle: resources.time_handle,
signal_handle: resources.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | f7a64538f7459e4dcdc05f6f944b6e553b1cef06 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f7a64538f7459e4dcdc05f6f944b6e553b1cef06/tokio/src/runtime/builder.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:19 | }
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 | f7a64538f7459e4dcdc05f6f944b6e553b1cef06 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f7a64538f7459e4dcdc05f6f944b6e553b1cef06/tokio/src/runtime/builder.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:20 | 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,
blocki... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | f7a64538f7459e4dcdc05f6f944b6e553b1cef06 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f7a64538f7459e4dcdc05f6f944b6e553b1cef06/tokio/src/runtime/builder.rs | 761 | 814 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:21 | .field("worker_threads", &self.worker_threads)
.field("max_blocking_threads", &self.max_blocking_threads)
.field(
"thread_name",
&"<dyn Fn() -> String + Send + Sync + 'static>",
)
.field("thread_stack_size", &self.thread_stack_size)
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | f7a64538f7459e4dcdc05f6f944b6e553b1cef06 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f7a64538f7459e4dcdc05f6f944b6e553b1cef06/tokio/src/runtime/builder.rs | 801 | 814 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:16 | /// Sets the number of scheduler ticks after which the scheduler will poll for
/// external events (timers, I/O, and so on).
///
/// A scheduler "tick" roughly corresponds to one `poll` invocation on a task.
///
/// By default, the event interval is `61` for all scheduler types.
///
/// Sett... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 0b8a3c34a1a119a61801b4e7e287f91684d11941 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b8a3c34a1a119a61801b4e7e287f91684d11941/tokio/src/runtime/builder.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:17 | 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 | 0b8a3c34a1a119a61801b4e7e287f91684d11941 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b8a3c34a1a119a61801b4e7e287f91684d11941/tokio/src/runtime/builder.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:18 | ///
/// ```
/// use tokio::runtime;
///
/// let rt = runtime::Builder::new_multi_thread()
/// .enable_io()
/// .build()
/// .unwrap();
/// ```
pub fn enable_io(&mut self) -> &mut Self {
self.enable_io = true;
sel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 0b8a3c34a1a119a61801b4e7e287f91684d11941 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b8a3c34a1a119a61801b4e7e287f91684d11941/tokio/src/runtime/builder.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:19 | 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
///
/// ```
/// use tokio::runtime;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 0b8a3c34a1a119a61801b4e7e287f91684d11941 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b8a3c34a1a119a61801b4e7e287f91684d11941/tokio/src/runtime/builder.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:20 | io_handle: resources.io_handle,
time_handle: resources.time_handle,
signal_handle: resources.signal_handle,
clock: resources.clock,
blocking_spawner,
};
let (scheduler, launch) = ThreadPool::new(
core_threads,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 0b8a3c34a1a119a61801b4e7e287f91684d11941 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b8a3c34a1a119a61801b4e7e287f91684d11941/tokio/src/runtime/builder.rs | 761 | 811 |
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 | 911a0efa87e36f0dffb13e3d52340d5c08415db1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/911a0efa87e36f0dffb13e3d52340d5c08415db1/tokio/src/runtime/builder.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:3 | }
pub(crate) type ThreadNameFn = std::sync::Arc<dyn Fn() -> String + Send + Sync + 'static>;
pub(crate) enum Kind {
CurrentThread,
#[cfg(feature = "rt-multi-thread")]
MultiThread,
}
impl Builder {
/// Returns a new builder with the current thread scheduler selected.
///
/// Configuration meth... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 911a0efa87e36f0dffb13e3d52340d5c08415db1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/911a0efa87e36f0dffb13e3d52340d5c08415db1/tokio/src/runtime/builder.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:4 | // I/O defaults to "off"
enable_io: false,
// Time defaults to "off"
enable_time: false,
// The clock starts not-paused
start_paused: false,
// Default to lazy auto-detection (one thread per CPU core)
worker_threads: None,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 911a0efa87e36f0dffb13e3d52340d5c08415db1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/911a0efa87e36f0dffb13e3d52340d5c08415db1/tokio/src/runtime/builder.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:9 | /// # 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 function... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 911a0efa87e36f0dffb13e3d52340d5c08415db1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/911a0efa87e36f0dffb13e3d52340d5c08415db1/tokio/src/runtime/builder.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:12 | /// if once.swap(false, Ordering::Relaxed) {
/// tokio::spawn(async move { barrier.wait().await; });
/// }
/// }
/// })
/// .build()
/// .unwrap();
///
/// runtime.block_on(async {
/// barrier.wait().await;
/// })
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 911a0efa87e36f0dffb13e3d52340d5c08415db1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/911a0efa87e36f0dffb13e3d52340d5c08415db1/tokio/src/runtime/builder.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:13 | /// })
/// .build();
///
/// 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 +... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 911a0efa87e36f0dffb13e3d52340d5c08415db1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/911a0efa87e36f0dffb13e3d52340d5c08415db1/tokio/src/runtime/builder.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:14 | fn get_cfg(&self) -> driver::Cfg {
driver::Cfg {
enable_pause_time: match self.kind {
Kind::CurrentThread => true,
#[cfg(feature = "rt-multi-thread")]
Kind::MultiThread => false,
},
enable_io: self.enable_io,
enable_... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 911a0efa87e36f0dffb13e3d52340d5c08415db1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/911a0efa87e36f0dffb13e3d52340d5c08415db1/tokio/src/runtime/builder.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:15 | // Blocking pool
let blocking_pool = blocking::create_blocking_pool(self, self.max_blocking_threads);
let blocking_spawner = blocking_pool.spawner().clone();
let handle_inner = HandleInner {
io_handle: resources.io_handle,
time_handle: resources.time_handle,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 911a0efa87e36f0dffb13e3d52340d5c08415db1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/911a0efa87e36f0dffb13e3d52340d5c08415db1/tokio/src/runtime/builder.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:17 | 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
///
/// ```
/// u... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 911a0efa87e36f0dffb13e3d52340d5c08415db1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/911a0efa87e36f0dffb13e3d52340d5c08415db1/tokio/src/runtime/builder.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:18 | io_handle: resources.io_handle,
time_handle: resources.time_handle,
signal_handle: resources.signal_handle,
clock: resources.clock,
blocking_spawner,
};
let (scheduler, launch) = ThreadPool::new(core_threads, driver, handle_inner, ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 911a0efa87e36f0dffb13e3d52340d5c08415db1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/911a0efa87e36f0dffb13e3d52340d5c08415db1/tokio/src/runtime/builder.rs | 681 | 725 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:14 | fn get_cfg(&self) -> driver::Cfg {
driver::Cfg {
enable_pause_time: match self.kind {
Kind::CurrentThread => true,
#[cfg(feature = "rt-multi-thread")]
Kind::MultiThread => false,
},
enable_io: self.enable_io,
enable_... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 957ed3eac07222a2d86ccfde8f29f29599f6f563 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/957ed3eac07222a2d86ccfde8f29f29599f6f563/tokio/src/runtime/builder.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:15 | // 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(driver, sel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 957ed3eac07222a2d86ccfde8f29f29599f6f563 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/957ed3eac07222a2d86ccfde8f29f29599f6f563/tokio/src/runtime/builder.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:17 | /// 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 | 957ed3eac07222a2d86ccfde8f29f29599f6f563 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/957ed3eac07222a2d86ccfde8f29f29599f6f563/tokio/src/runtime/builder.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:18 | spawner,
io_handle: resources.io_handle,
time_handle: resources.time_handle,
signal_handle: resources.signal_handle,
clock: resources.clock,
blocking_spawner,
};
// Spawn the thread pool workers
let _ent... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 957ed3eac07222a2d86ccfde8f29f29599f6f563 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/957ed3eac07222a2d86ccfde8f29f29599f6f563/tokio/src/runtime/builder.rs | 681 | 718 |
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 | 08ed41f339e345286f26bdbc6c67bf9f2975ed07 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/src/runtime/builder.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:3 | #[cfg(feature = "rt-multi-thread")]
MultiThread,
}
impl Builder {
/// Returns a new builder with the current thread scheduler selected.
///
/// Configuration methods can be chained on the return value.
///
/// To spawn non-`Send` tasks on the resulting runtime, combine it with a
/// [`Local... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 08ed41f339e345286f26bdbc6c67bf9f2975ed07 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/src/runtime/builder.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:4 | // The clock starts not-paused
start_paused: false,
// Default to lazy auto-detection (one thread per CPU core)
worker_threads: None,
max_blocking_threads: 512,
// Default thread name
thread_name: std::sync::Arc::new(|| "tokio-runtime-worker".in... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 08ed41f339e345286f26bdbc6c67bf9f2975ed07 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/src/runtime/builder.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:7 | /// [`spawn_blocking`]: fn@crate::task::spawn_blocking
/// [`worker_threads`]: Self::worker_threads
/// [`thread_keep_alive`]: Self::thread_keep_alive
#[cfg_attr(docsrs, doc(alias = "max_threads"))]
pub fn max_blocking_threads(&mut self, val: usize) -> &mut Self {
assert!(val > 0, "Max blocking ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 08ed41f339e345286f26bdbc6c67bf9f2975ed07 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/src/runtime/builder.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:9 | self
}
/// Executes function `f` after each thread is started but before it starts
/// doing work.
///
/// This is intended for bookkeeping and monitoring use cases.
///
/// # Examples
///
/// ```
/// # use tokio::runtime;
///
/// # pub fn main() {
/// let runtime = ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 08ed41f339e345286f26bdbc6c67bf9f2975ed07 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/src/runtime/builder.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:10 | /// let runtime = runtime::Builder::new_multi_thread()
/// .on_thread_stop(|| {
/// println!("thread stopping");
/// })
/// .build();
/// # }
/// ```
#[cfg(not(loom))]
pub fn on_thread_stop<F>(&mut self, f: F) -> &mut Self
where
F: Fn() + Send + Sync + 'st... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 08ed41f339e345286f26bdbc6c67bf9f2975ed07 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/src/runtime/builder.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:11 | driver::Cfg {
enable_pause_time: match self.kind {
Kind::CurrentThread => true,
#[cfg(feature = "rt-multi-thread")]
Kind::MultiThread => false,
},
enable_io: self.enable_io,
enable_time: self.enable_time,
start_p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 08ed41f339e345286f26bdbc6c67bf9f2975ed07 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/src/runtime/builder.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:12 | // 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(driver);
let spawner = Spawner::Basic(scheduler.spawner().clone());
// Blocking poo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 08ed41f339e345286f26bdbc6c67bf9f2975ed07 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/src/runtime/builder.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:14 | ///
/// ```
/// use tokio::runtime;
///
/// let rt = runtime::Builder::new_current_thread()
/// .enable_time()
/// .start_paused(true)
/// .build()
/// .unwrap();
/// ```
pub fn start_paused(&mut self, start_paused: bool) ->... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 08ed41f339e345286f26bdbc6c67bf9f2975ed07 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/src/runtime/builder.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:15 | signal_handle: resources.signal_handle,
clock: resources.clock,
blocking_spawner,
};
// Spawn the thread pool workers
let _enter = crate::runtime::context::enter(handle.clone());
launch.launch();
Ok(Runtime {
k... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 08ed41f339e345286f26bdbc6c67bf9f2975ed07 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/src/runtime/builder.rs | 561 | 593 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:10 | /// let runtime = runtime::Builder::new_multi_thread()
/// .on_thread_stop(|| {
/// println!("thread stopping");
/// })
/// .build();
/// # }
/// ```
#[cfg(not(loom))]
pub fn on_thread_stop<F>(&mut self, f: F) -> &mut Self
where
F: Fn() + Send + Sync + 'st... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 8efed43fa727e1807c7bc89ac6963a14c2d72c9a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8efed43fa727e1807c7bc89ac6963a14c2d72c9a/tokio/src/runtime/builder.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:11 | driver::Cfg {
enable_pause_time: match self.kind {
Kind::CurrentThread => true,
#[cfg(feature = "rt-multi-thread")]
Kind::MultiThread => false,
},
enable_io: self.enable_io,
enable_time: self.enable_time,
start_p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 8efed43fa727e1807c7bc89ac6963a14c2d72c9a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8efed43fa727e1807c7bc89ac6963a14c2d72c9a/tokio/src/runtime/builder.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:4 | // The clock starts not-paused
start_paused: false,
// Default to lazy auto-detection (one thread per CPU core)
worker_threads: None,
max_blocking_threads: 512,
// Default thread name
thread_name: std::sync::Arc::new(|| "tokio-runtime-worker".in... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 6fd06aaeecce21bcf31cbe485fe0060e3f07e983 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd06aaeecce21bcf31cbe485fe0060e3f07e983/tokio/src/runtime/builder.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:7 | #[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 | 6fd06aaeecce21bcf31cbe485fe0060e3f07e983 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd06aaeecce21bcf31cbe485fe0060e3f07e983/tokio/src/runtime/builder.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:9 | /// Executes function `f` after each thread is started but before it starts
/// doing work.
///
/// This is intended for bookkeeping and monitoring use cases.
///
/// # Examples
///
/// ```
/// # use tokio::runtime;
///
/// # pub fn main() {
/// let runtime = runtime::Builder... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 6fd06aaeecce21bcf31cbe485fe0060e3f07e983 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd06aaeecce21bcf31cbe485fe0060e3f07e983/tokio/src/runtime/builder.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:10 | /// })
/// .build();
/// # }
/// ```
#[cfg(not(loom))]
pub fn on_thread_stop<F>(&mut self, f: F) -> &mut Self
where
F: Fn() + Send + Sync + 'static,
{
self.before_stop = Some(std::sync::Arc::new(f));
self
}
/// Creates the configured `Runtime`.
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 6fd06aaeecce21bcf31cbe485fe0060e3f07e983 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd06aaeecce21bcf31cbe485fe0060e3f07e983/tokio/src/runtime/builder.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:11 | #[cfg(feature = "rt-multi-thread")]
Kind::MultiThread => false,
},
enable_io: self.enable_io,
enable_time: self.enable_time,
start_paused: self.start_paused,
}
}
/// Sets a custom timeout for a thread in the blocking pool.
///
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 6fd06aaeecce21bcf31cbe485fe0060e3f07e983 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd06aaeecce21bcf31cbe485fe0060e3f07e983/tokio/src/runtime/builder.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:12 | let scheduler = BasicScheduler::new(driver);
let spawner = Spawner::Basic(scheduler.spawner().clone());
// Blocking pool
let blocking_pool = blocking::create_blocking_pool(self, self.max_blocking_threads);
let blocking_spawner = blocking_pool.spawner().clone();
Ok(Runtime {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 6fd06aaeecce21bcf31cbe485fe0060e3f07e983 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd06aaeecce21bcf31cbe485fe0060e3f07e983/tokio/src/runtime/builder.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:13 | self.enable_io = true;
self
}
}
}
cfg_time! {
impl Builder {
/// Enables the time driver.
///
/// Doing this enables using `tokio::time` on the runtime.
///
/// # Examples
///
/// ```
/// use tokio::runtime;
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 6fd06aaeecce21bcf31cbe485fe0060e3f07e983 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd06aaeecce21bcf31cbe485fe0060e3f07e983/tokio/src/runtime/builder.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:14 | ///
/// let rt = runtime::Builder::new_current_thread()
/// .enable_time()
/// .start_paused(true)
/// .build()
/// .unwrap();
/// ```
pub fn start_paused(&mut self, start_paused: bool) -> &mut Self {
self.start_paused = start_paused;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 6fd06aaeecce21bcf31cbe485fe0060e3f07e983 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd06aaeecce21bcf31cbe485fe0060e3f07e983/tokio/src/runtime/builder.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:15 | };
// Spawn the thread pool workers
let _enter = crate::runtime::context::enter(handle.clone());
launch.launch();
Ok(Runtime {
kind: Kind::ThreadPool(scheduler),
handle,
blocking_pool,
})
}
}
}
imp... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 6fd06aaeecce21bcf31cbe485fe0060e3f07e983 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd06aaeecce21bcf31cbe485fe0060e3f07e983/tokio/src/runtime/builder.rs | 561 | 590 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:6 | /// ```
/// use tokio::runtime;
///
/// // Create a runtime that _must_ be driven from a call
/// // to `Runtime::block_on`.
/// let rt = runtime::Builder::new_current_thread()
/// .build()
/// .unwrap();
///
/// // This will run the runtime and future on the current thread
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 6fd9084d470aa34e02c9dedcbf52e310fcb9cacc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd9084d470aa34e02c9dedcbf52e310fcb9cacc/tokio/src/runtime/builder.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:8 | /// # }
/// ```
pub fn thread_name_fn<F>(&mut self, f: F) -> &mut Self
where
F: Fn() -> String + Send + Sync + 'static,
{
self.thread_name = std::sync::Arc::new(f);
self
}
/// Sets the stack size (in bytes) for worker threads.
///
/// The actual stack size may be... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 6fd9084d470aa34e02c9dedcbf52e310fcb9cacc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd9084d470aa34e02c9dedcbf52e310fcb9cacc/tokio/src/runtime/builder.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:9 | ///
/// ```
/// # use tokio::runtime;
///
/// # pub fn main() {
/// let runtime = runtime::Builder::new_multi_thread()
/// .on_thread_start(|| {
/// println!("thread started");
/// })
/// .build();
/// # }
/// ```
#[cfg(not(loom))]
pub fn on_thread... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 6fd9084d470aa34e02c9dedcbf52e310fcb9cacc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd9084d470aa34e02c9dedcbf52e310fcb9cacc/tokio/src/runtime/builder.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:10 | where
F: Fn() + Send + Sync + 'static,
{
self.before_stop = 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 | 6fd9084d470aa34e02c9dedcbf52e310fcb9cacc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd9084d470aa34e02c9dedcbf52e310fcb9cacc/tokio/src/runtime/builder.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:11 | }
}
/// Sets a custom timeout for a thread in the blocking pool.
///
/// By default, the timeout for a thread is set to 10 seconds. This can
/// be overriden using .thread_keep_alive().
///
/// # Example
///
/// ```
/// # use tokio::runtime;
/// # use std::time::Duration;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 6fd9084d470aa34e02c9dedcbf52e310fcb9cacc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd9084d470aa34e02c9dedcbf52e310fcb9cacc/tokio/src/runtime/builder.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:12 | Ok(Runtime {
kind: Kind::CurrentThread(scheduler),
handle: Handle {
spawner,
io_handle: resources.io_handle,
time_handle: resources.time_handle,
signal_handle: resources.signal_handle,
clock: resources.clock,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 6fd9084d470aa34e02c9dedcbf52e310fcb9cacc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd9084d470aa34e02c9dedcbf52e310fcb9cacc/tokio/src/runtime/builder.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:13 | cfg_time! {
impl Builder {
/// Enables the time driver.
///
/// Doing this enables using `tokio::time` 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 | 6fd9084d470aa34e02c9dedcbf52e310fcb9cacc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd9084d470aa34e02c9dedcbf52e310fcb9cacc/tokio/src/runtime/builder.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:14 | /// ```
pub fn start_paused(&mut self, start_paused: bool) -> &mut Self {
self.start_paused = start_paused;
self
}
}
}
cfg_rt_multi_thread! {
impl Builder {
fn build_threaded_runtime(&mut self) -> io::Result<Runtime> {
use crate::loom::sys::num_cpus;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 6fd9084d470aa34e02c9dedcbf52e310fcb9cacc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd9084d470aa34e02c9dedcbf52e310fcb9cacc/tokio/src/runtime/builder.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:15 | Ok(Runtime {
kind: Kind::ThreadPool(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",... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | 6fd9084d470aa34e02c9dedcbf52e310fcb9cacc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6fd9084d470aa34e02c9dedcbf52e310fcb9cacc/tokio/src/runtime/builder.rs | 561 | 584 |
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 | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/runtime/builder.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:3 | #[cfg(feature = "rt-multi-thread")]
MultiThread,
}
impl Builder {
/// Returns a new builder with the current thread scheduler selected.
///
/// Configuration methods can be chained on the return value.
pub fn new_current_thread() -> Builder {
Builder::new(Kind::CurrentThread)
}
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/runtime/builder.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:4 | 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 | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/runtime/builder.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:6 | /// let rt = runtime::Builder::new_current_thread()
/// .build()
/// .unwrap();
///
/// // This will run the runtime and future on the current thread
/// rt.block_on(async move {});
/// ```
///
/// # Panic
///
/// This will panic if `val` is not larger than `0`.
pub f... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/runtime/builder.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:8 | {
self.thread_name = std::sync::Arc::new(f);
self
}
/// Sets the stack size (in bytes) for worker threads.
///
/// The actual stack size may be greater than this value if the platform
/// specifies minimal stack size.
///
/// The default stack size for spawned threads is 2 M... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/runtime/builder.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:9 | /// let runtime = runtime::Builder::new_multi_thread()
/// .on_thread_start(|| {
/// println!("thread started");
/// })
/// .build();
/// # }
/// ```
#[cfg(not(loom))]
pub fn on_thread_start<F>(&mut self, f: F) -> &mut Self
where
F: Fn() + Send + Sync + 's... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/runtime/builder.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:10 | }
/// 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 | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/runtime/builder.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:11 | /// By default, the timeout for a thread is set to 10 seconds. This can
/// be overriden using .thread_keep_alive().
///
/// # Example
///
/// ```
/// # use tokio::runtime;
/// # use std::time::Duration;
///
/// # pub fn main() {
/// let rt = runtime::Builder::new_multi_thread()
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/runtime/builder.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:12 | io_handle: resources.io_handle,
time_handle: resources.time_handle,
signal_handle: resources.signal_handle,
clock: resources.clock,
blocking_spawner,
},
blocking_pool,
})
}
}
cfg_io_driver! {
impl Builder {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/runtime/builder.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:13 | ///
/// # Examples
///
/// ```
/// use tokio::runtime;
///
/// let rt = runtime::Builder::new_multi_thread()
/// .enable_time()
/// .build()
/// .unwrap();
/// ```
pub fn enable_time(&mut self) -> &mut Self {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/runtime/builder.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:14 | }
}
cfg_rt_multi_thread! {
impl Builder {
fn build_threaded_runtime(&mut self) -> io::Result<Runtime> {
use crate::loom::sys::num_cpus;
use crate::runtime::{Kind, ThreadPool};
use crate::runtime::park::Parker;
let core_threads = self.worker_threads.unwrap_or... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/runtime/builder.rs | 521 | 579 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:15 | }
}
}
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 | fcb6d041b9d2fe567b5306e648cbb048b426a49d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fcb6d041b9d2fe567b5306e648cbb048b426a49d/tokio/src/runtime/builder.rs | 561 | 579 |
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,
/// The number of worker threads, used by Runtime.
///
/// Only used when not using the current-thread executor.
worker_threads... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b99b00eb302ae6ff19ca97d32b1e594143f43a60 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b99b00eb302ae6ff19ca97d32b1e594143f43a60/tokio/src/runtime/builder.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:3 | impl Builder {
/// Returns a new builder with the current thread scheduler selected.
///
/// Configuration methods can be chained on the return value.
pub fn new_current_thread() -> Builder {
Builder::new(Kind::CurrentThread)
}
/// Returns a new builder with the multi thread scheduler s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b99b00eb302ae6ff19ca97d32b1e594143f43a60 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b99b00eb302ae6ff19ca97d32b1e594143f43a60/tokio/src/runtime/builder.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/builder.rs:4 | // Do not set a stack size by default
thread_stack_size: None,
// No worker thread callbacks
after_start: None,
before_stop: None,
keep_alive: None,
}
}
/// Enables both I/O and time drivers.
///
/// Doing this is a shorthand for cal... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/builder.rs | MIT | b99b00eb302ae6ff19ca97d32b1e594143f43a60 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b99b00eb302ae6ff19ca97d32b1e594143f43a60/tokio/src/runtime/builder.rs | 121 | 180 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.