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/runtime.rs:1 | use super::BOX_FUTURE_THRESHOLD;
use crate::runtime::blocking::BlockingPool;
use crate::runtime::scheduler::CurrentThread;
use crate::runtime::{context, EnterGuard, Handle};
use crate::task::JoinHandle;
use crate::util::trace::SpawnMeta;
use std::future::Future;
use std::mem;
use std::time::Duration;
cfg_rt_multi_thr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 2052938a9f743b308f193665f8ccedd827c139b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2052938a9f743b308f193665f8ccedd827c139b1/tokio/src/runtime/runtime.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:3 | ///
/// The runtime context is entered using the [`Runtime::enter`] or
/// [`Handle::enter`] methods, which use a thread-local variable to store the
/// current runtime. Whenever you are inside the runtime context, methods such
/// as [`tokio::spawn`] will use the runtime whose context you are inside.
///
/// [timer]: ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 2052938a9f743b308f193665f8ccedd827c139b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2052938a9f743b308f193665f8ccedd827c139b1/tokio/src/runtime/runtime.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:4 | #[cfg(tokio_unstable)]
#[cfg_attr(docsrs, doc(cfg(tokio_unstable)))]
MultiThreadAlt,
}
/// The runtime scheduler is either a multi-thread or a current-thread executor.
#[derive(Debug)]
pub(super) enum Scheduler {
/// Execute all tasks on the current-thread.
CurrentThread(CurrentThread),
/// Execut... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 2052938a9f743b308f193665f8ccedd827c139b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2052938a9f743b308f193665f8ccedd827c139b1/tokio/src/runtime/runtime.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:6 | /// let rt = Runtime::new()
/// .unwrap();
///
/// let handle = rt.handle();
///
/// // Use the handle...
/// ```
pub fn handle(&self) -> &Handle {
&self.handle
}
/// Spawns a future onto the Tokio runtime.
///
/// This spawns the given future onto the runtime's ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 2052938a9f743b308f193665f8ccedd827c139b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2052938a9f743b308f193665f8ccedd827c139b1/tokio/src/runtime/runtime.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:7 | #[track_caller]
pub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
where
F: Future + Send + 'static,
F::Output: Send + 'static,
{
let fut_size = mem::size_of::<F>();
if fut_size > BOX_FUTURE_THRESHOLD {
self.handle
.spawn_named(Box::pin(fut... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 2052938a9f743b308f193665f8ccedd827c139b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2052938a9f743b308f193665f8ccedd827c139b1/tokio/src/runtime/runtime.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:9 | /// # Examples
///
/// ```no_run
/// use tokio::runtime::Runtime;
///
/// // Create the runtime
/// let rt = Runtime::new().unwrap();
///
/// // Execute the future, blocking the current thread until completion
/// rt.block_on(async {
/// println!("hello");
/// });
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 2052938a9f743b308f193665f8ccedd827c139b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2052938a9f743b308f193665f8ccedd827c139b1/tokio/src/runtime/runtime.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:10 | _meta,
crate::runtime::task::Id::next().as_u64(),
);
let _enter = self.enter();
match &self.scheduler {
Scheduler::CurrentThread(exec) => exec.block_on(&self.handle.inner, future),
#[cfg(feature = "rt-multi-thread")]
Scheduler::MultiThread(exec) ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 2052938a9f743b308f193665f8ccedd827c139b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2052938a9f743b308f193665f8ccedd827c139b1/tokio/src/runtime/runtime.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12 | /// }
/// ```
pub fn shutdown_timeout(mut self, duration: Duration) {
// Wakeup and shutdown all the worker threads
self.handle.inner.shutdown();
self.blocking_pool.shutdown(Some(duration));
}
/// Shuts down the runtime, without waiting for any spawned work to stop.
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 2052938a9f743b308f193665f8ccedd827c139b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2052938a9f743b308f193665f8ccedd827c139b1/tokio/src/runtime/runtime.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:13 | /// Returns a view that lets you get information about how the runtime
/// is performing.
pub fn metrics(&self) -> crate::runtime::RuntimeMetrics {
self.handle.metrics()
}
}
#[allow(clippy::single_match)] // there are comments in the error branch, so we don't want if-let
impl Drop for Runtime {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 2052938a9f743b308f193665f8ccedd827c139b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2052938a9f743b308f193665f8ccedd827c139b1/tokio/src/runtime/runtime.rs | 481 | 516 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12 | /// ```
pub fn shutdown_timeout(mut self, duration: Duration) {
// Wakeup and shutdown all the worker threads
self.handle.inner.shutdown();
self.blocking_pool.shutdown(Some(duration));
}
/// Shuts down the runtime, without waiting for any spawned work to stop.
///
/// This c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 92ccadeb3c7058cdc8799b998f6a19a1171691df | github | async-runtime | https://github.com/tokio-rs/tokio/blob/92ccadeb3c7058cdc8799b998f6a19a1171691df/tokio/src/runtime/runtime.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:13 | /// is performing.
pub fn metrics(&self) -> crate::runtime::RuntimeMetrics {
self.handle.metrics()
}
}
#[allow(clippy::single_match)] // there are comments in the error branch, so we don't want if-let
impl Drop for Runtime {
fn drop(&mut self) {
match &mut self.scheduler {
Sched... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 92ccadeb3c7058cdc8799b998f6a19a1171691df | github | async-runtime | https://github.com/tokio-rs/tokio/blob/92ccadeb3c7058cdc8799b998f6a19a1171691df/tokio/src/runtime/runtime.rs | 481 | 515 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:3 | ///
/// The runtime context is entered using the [`Runtime::enter`] or
/// [`Handle::enter`] methods, which use a thread-local variable to store the
/// current runtime. Whenever you are inside the runtime context, methods such
/// as [`tokio::spawn`] will use the runtime whose context you are inside.
///
/// [timer]: ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | c3a935541d911cd9afa6838a1bb02e4f499b244d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/runtime/runtime.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:4 | #[cfg(tokio_unstable)]
MultiThreadAlt,
}
/// The runtime scheduler is either a multi-thread or a current-thread executor.
#[derive(Debug)]
pub(super) enum Scheduler {
/// Execute all tasks on the current-thread.
CurrentThread(CurrentThread),
/// Execute tasks across multiple threads.
#[cfg(feature... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | c3a935541d911cd9afa6838a1bb02e4f499b244d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/runtime/runtime.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:6 | /// .unwrap();
///
/// let handle = rt.handle();
///
/// // Use the handle...
/// ```
pub fn handle(&self) -> &Handle {
&self.handle
}
/// Spawns a future onto the Tokio runtime.
///
/// This spawns the given future onto the runtime's executor, usually a
/// thre... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | c3a935541d911cd9afa6838a1bb02e4f499b244d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/runtime/runtime.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:7 | pub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
where
F: Future + Send + 'static,
F::Output: Send + 'static,
{
let fut_size = mem::size_of::<F>();
if fut_size > BOX_FUTURE_THRESHOLD {
self.handle
.spawn_named(Box::pin(future), SpawnMeta::new... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | c3a935541d911cd9afa6838a1bb02e4f499b244d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/runtime/runtime.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:9 | ///
/// ```no_run
/// use tokio::runtime::Runtime;
///
/// // Create the runtime
/// let rt = Runtime::new().unwrap();
///
/// // Execute the future, blocking the current thread until completion
/// rt.block_on(async {
/// println!("hello");
/// });
/// ```
///
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | c3a935541d911cd9afa6838a1bb02e4f499b244d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/runtime/runtime.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:10 | crate::runtime::task::Id::next().as_u64(),
);
let _enter = self.enter();
match &self.scheduler {
Scheduler::CurrentThread(exec) => exec.block_on(&self.handle.inner, future),
#[cfg(feature = "rt-multi-thread")]
Scheduler::MultiThread(exec) => exec.block_on(&s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | c3a935541d911cd9afa6838a1bb02e4f499b244d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/runtime/runtime.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12 | pub fn shutdown_timeout(mut self, duration: Duration) {
// Wakeup and shutdown all the worker threads
self.handle.inner.shutdown();
self.blocking_pool.shutdown(Some(duration));
}
/// Shuts down the runtime, without waiting for any spawned work to stop.
///
/// This can be useful... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | c3a935541d911cd9afa6838a1bb02e4f499b244d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/runtime/runtime.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:13 | pub fn metrics(&self) -> crate::runtime::RuntimeMetrics {
self.handle.metrics()
}
}
#[allow(clippy::single_match)] // there are comments in the error branch, so we don't want if-let
impl Drop for Runtime {
fn drop(&mut self) {
match &mut self.scheduler {
Scheduler::CurrentThread(cur... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | c3a935541d911cd9afa6838a1bb02e4f499b244d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/runtime/runtime.rs | 481 | 514 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:1 | use super::BOX_FUTURE_THRESHOLD;
use crate::runtime::blocking::BlockingPool;
use crate::runtime::scheduler::CurrentThread;
use crate::runtime::{context, EnterGuard, Handle};
use crate::task::JoinHandle;
use std::future::Future;
use std::time::Duration;
cfg_rt_multi_thread! {
use crate::runtime::Builder;
use c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | b5de84d19b4316caccfe13aa7552d895bdd7f046 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/runtime/runtime.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:3 | /// [`Handle::enter`] methods, which use a thread-local variable to store the
/// current runtime. Whenever you are inside the runtime context, methods such
/// as [`tokio::spawn`] will use the runtime whose context you are inside.
///
/// [timer]: crate::time
/// [mod]: index.html
/// [`new`]: method@Self::new
/// [`B... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | b5de84d19b4316caccfe13aa7552d895bdd7f046 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/runtime/runtime.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:4 | }
/// The runtime scheduler is either a multi-thread or a current-thread executor.
#[derive(Debug)]
pub(super) enum Scheduler {
/// Execute all tasks on the current-thread.
CurrentThread(CurrentThread),
/// Execute tasks across multiple threads.
#[cfg(feature = "rt-multi-thread")]
MultiThread(Mult... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | b5de84d19b4316caccfe13aa7552d895bdd7f046 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/runtime/runtime.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:6 | /// let handle = rt.handle();
///
/// // Use the handle...
/// ```
pub fn handle(&self) -> &Handle {
&self.handle
}
/// Spawns a future onto the Tokio runtime.
///
/// This spawns the given future onto the runtime's executor, usually a
/// thread pool. The thread pool is the... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | b5de84d19b4316caccfe13aa7552d895bdd7f046 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/runtime/runtime.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:7 | F: Future + Send + 'static,
F::Output: Send + 'static,
{
if std::mem::size_of::<F>() > BOX_FUTURE_THRESHOLD {
self.handle.spawn_named(Box::pin(future), None)
} else {
self.handle.spawn_named(future, None)
}
}
/// Runs the provided function on an execu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | b5de84d19b4316caccfe13aa7552d895bdd7f046 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/runtime/runtime.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:9 | /// let rt = Runtime::new().unwrap();
///
/// // Execute the future, blocking the current thread until completion
/// rt.block_on(async {
/// println!("hello");
/// });
/// ```
///
/// [handle]: fn@Handle::block_on
#[track_caller]
pub fn block_on<F: Future>(&self, future: F)... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | b5de84d19b4316caccfe13aa7552d895bdd7f046 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/runtime/runtime.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12 | /// Shuts down the runtime, without waiting for any spawned work to stop.
///
/// This can be useful if you want to drop a runtime from within another runtime.
/// Normally, dropping a runtime will block indefinitely for spawned blocking tasks
/// to complete, which would normally not be permitted withi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | b5de84d19b4316caccfe13aa7552d895bdd7f046 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/runtime/runtime.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:13 | impl Drop for Runtime {
fn drop(&mut self) {
match &mut self.scheduler {
Scheduler::CurrentThread(current_thread) => {
// This ensures that tasks spawned on the current-thread
// runtime are dropped inside the runtime's context.
let _guard = contex... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | b5de84d19b4316caccfe13aa7552d895bdd7f046 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/runtime/runtime.rs | 481 | 508 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:6 | /// let handle = rt.handle();
///
/// // Use the handle...
/// ```
pub fn handle(&self) -> &Handle {
&self.handle
}
/// Spawns a future onto the Tokio runtime.
///
/// This spawns the given future onto the runtime's executor, usually a
/// thread pool. The thread pool is the... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | da17c6146413d9ea14f76989efe31ef7de829f4c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/da17c6146413d9ea14f76989efe31ef7de829f4c/tokio/src/runtime/runtime.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:7 | F: Future + Send + 'static,
F::Output: Send + 'static,
{
if cfg!(debug_assertions) && std::mem::size_of::<F>() > BOX_FUTURE_THRESHOLD {
self.handle.spawn_named(Box::pin(future), None)
} else {
self.handle.spawn_named(future, None)
}
}
/// Runs the pro... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | da17c6146413d9ea14f76989efe31ef7de829f4c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/da17c6146413d9ea14f76989efe31ef7de829f4c/tokio/src/runtime/runtime.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:9 | /// let rt = Runtime::new().unwrap();
///
/// // Execute the future, blocking the current thread until completion
/// rt.block_on(async {
/// println!("hello");
/// });
/// ```
///
/// [handle]: fn@Handle::block_on
#[track_caller]
pub fn block_on<F: Future>(&self, future: F)... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | da17c6146413d9ea14f76989efe31ef7de829f4c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/da17c6146413d9ea14f76989efe31ef7de829f4c/tokio/src/runtime/runtime.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:3 | /// current runtime. Whenever you are inside the runtime context, methods such
/// as [`tokio::spawn`] will use the runtime whose context you are inside.
///
/// [timer]: crate::time
/// [mod]: index.html
/// [`new`]: method@Self::new
/// [`Builder`]: struct@Builder
/// [`Handle`]: struct@Handle
/// [main]: macro@crate... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 86658bd87dc470f8e36eb6b893cc403820cfb7ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/86658bd87dc470f8e36eb6b893cc403820cfb7ee/tokio/src/runtime/runtime.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:4 | /// The runtime scheduler is either a multi-thread or a current-thread executor.
#[derive(Debug)]
pub(super) enum Scheduler {
/// Execute all tasks on the current-thread.
CurrentThread(CurrentThread),
/// Execute tasks across multiple threads.
#[cfg(feature = "rt-multi-thread")]
MultiThread(MultiTh... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 86658bd87dc470f8e36eb6b893cc403820cfb7ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/86658bd87dc470f8e36eb6b893cc403820cfb7ee/tokio/src/runtime/runtime.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:8 | /// Note that the future required by this function does not run as a
/// worker. The expectation is that other tasks are spawned by the future here.
/// Awaiting on other futures from the future provided here will not
/// perform as fast as those spawned as workers.
///
/// # Multi thread scheduler
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 86658bd87dc470f8e36eb6b893cc403820cfb7ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/86658bd87dc470f8e36eb6b893cc403820cfb7ee/tokio/src/runtime/runtime.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:9 | /// });
/// ```
///
/// [handle]: fn@Handle::block_on
#[track_caller]
pub fn block_on<F: Future>(&self, future: F) -> F::Output {
#[cfg(all(
tokio_unstable,
tokio_taskdump,
feature = "rt",
target_os = "linux",
any(target_arch = "aar... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 86658bd87dc470f8e36eb6b893cc403820cfb7ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/86658bd87dc470f8e36eb6b893cc403820cfb7ee/tokio/src/runtime/runtime.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12 | ///
/// ```
/// use tokio::runtime::Runtime;
///
/// fn main() {
/// let runtime = Runtime::new().unwrap();
///
/// runtime.block_on(async move {
/// let inner_runtime = Runtime::new().unwrap();
/// // ...
/// inner_runtime.shutdown_background();
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 86658bd87dc470f8e36eb6b893cc403820cfb7ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/86658bd87dc470f8e36eb6b893cc403820cfb7ee/tokio/src/runtime/runtime.rs | 441 | 494 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:13 | }
#[cfg(all(tokio_unstable, feature = "rt-multi-thread"))]
Scheduler::MultiThreadAlt(multi_thread) => {
// The threaded scheduler drops its tasks on its worker threads, which is
// already in the runtime's context.
multi_thread.shutdown(&self.handl... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 86658bd87dc470f8e36eb6b893cc403820cfb7ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/86658bd87dc470f8e36eb6b893cc403820cfb7ee/tokio/src/runtime/runtime.rs | 481 | 494 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12 | ///
/// ```
/// use tokio::runtime::Runtime;
///
/// fn main() {
/// let runtime = Runtime::new().unwrap();
///
/// runtime.block_on(async move {
/// let inner_runtime = Runtime::new().unwrap();
/// // ...
/// inner_runtime.shutdown_background();
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 9ed595767d01c400955122d276b34ab52b3a6aab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9ed595767d01c400955122d276b34ab52b3a6aab/tokio/src/runtime/runtime.rs | 441 | 498 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:13 | }
}
}
}
impl std::panic::UnwindSafe for Runtime {}
impl std::panic::RefUnwindSafe for Runtime {}
cfg_metrics! {
impl Runtime {
/// Returns a view that lets you get information about how the runtime
/// is performing.
pub fn metrics(&self) -> crate::runtime::RuntimeMetrics {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 9ed595767d01c400955122d276b34ab52b3a6aab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9ed595767d01c400955122d276b34ab52b3a6aab/tokio/src/runtime/runtime.rs | 481 | 498 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:3 | /// current runtime. Whenever you are inside the runtime context, methods such
/// as [`tokio::spawn`] will use the runtime whose context you are inside.
///
/// [timer]: crate::time
/// [mod]: index.html
/// [`new`]: method@Self::new
/// [`Builder`]: struct@Builder
/// [`Handle`]: struct@Handle
/// [main]: macro@crate... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | f3bfed30eb66d60c3c28691c1dd040c6531a337b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3bfed30eb66d60c3c28691c1dd040c6531a337b/tokio/src/runtime/runtime.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:4 | /// The runtime scheduler is either a multi-thread or a current-thread executor.
#[derive(Debug)]
pub(super) enum Scheduler {
/// Execute all tasks on the current-thread.
CurrentThread(CurrentThread),
/// Execute tasks across multiple threads.
#[cfg(all(feature = "rt-multi-thread", not(target_os = "was... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | f3bfed30eb66d60c3c28691c1dd040c6531a337b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3bfed30eb66d60c3c28691c1dd040c6531a337b/tokio/src/runtime/runtime.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:7 | where
F: Future + Send + 'static,
F::Output: Send + 'static,
{
self.handle.spawn(future)
}
/// Runs the provided function on an executor dedicated to blocking operations.
///
/// # Examples
///
/// ```
/// use tokio::runtime::Runtime;
///
/// # fn dox() {... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | f3bfed30eb66d60c3c28691c1dd040c6531a337b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3bfed30eb66d60c3c28691c1dd040c6531a337b/tokio/src/runtime/runtime.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:9 | /// rt.block_on(async {
/// println!("hello");
/// });
/// ```
///
/// [handle]: fn@Handle::block_on
#[track_caller]
pub fn block_on<F: Future>(&self, future: F) -> F::Output {
#[cfg(all(
tokio_unstable,
tokio_taskdump,
feature = "rt",
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | f3bfed30eb66d60c3c28691c1dd040c6531a337b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3bfed30eb66d60c3c28691c1dd040c6531a337b/tokio/src/runtime/runtime.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12 | ///
/// This function is equivalent to calling `shutdown_timeout(Duration::from_nanos(0))`.
///
/// ```
/// use tokio::runtime::Runtime;
///
/// fn main() {
/// let runtime = Runtime::new().unwrap();
///
/// runtime.block_on(async move {
/// let inner_runtime = Runti... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | f3bfed30eb66d60c3c28691c1dd040c6531a337b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3bfed30eb66d60c3c28691c1dd040c6531a337b/tokio/src/runtime/runtime.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:13 | // already in the runtime's context.
multi_thread.shutdown(&self.handle.inner);
}
}
}
}
impl std::panic::UnwindSafe for Runtime {}
impl std::panic::RefUnwindSafe for Runtime {}
cfg_metrics! {
impl Runtime {
/// Returns a view that lets you get information about how... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | f3bfed30eb66d60c3c28691c1dd040c6531a337b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3bfed30eb66d60c3c28691c1dd040c6531a337b/tokio/src/runtime/runtime.rs | 481 | 500 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12 | ///
/// This function is equivalent to calling `shutdown_timeout(Duration::from_nanos(0))`.
///
/// ```
/// use tokio::runtime::Runtime;
///
/// fn main() {
/// let runtime = Runtime::new().unwrap();
///
/// runtime.block_on(async move {
/// let inner_runtime = Runti... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 3133af42e123b9469dad292ae3a090da915d23c5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3133af42e123b9469dad292ae3a090da915d23c5/tokio/src/runtime/runtime.rs | 441 | 499 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:13 | // already in the runtime's context.
multi_thread.shutdown(&self.handle.inner);
}
}
}
}
impl std::panic::UnwindSafe for Runtime {}
impl std::panic::RefUnwindSafe for Runtime {}
cfg_metrics! {
impl Runtime {
/// TODO
pub fn metrics(&self) -> crate::runtime::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 3133af42e123b9469dad292ae3a090da915d23c5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3133af42e123b9469dad292ae3a090da915d23c5/tokio/src/runtime/runtime.rs | 481 | 499 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:9 | /// rt.block_on(async {
/// println!("hello");
/// });
/// ```
///
/// [handle]: fn@Handle::block_on
#[track_caller]
pub fn block_on<F: Future>(&self, future: F) -> F::Output {
#[cfg(all(
tokio_unstable,
tokio_taskdump,
feature = "rt",
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 5658d7c5032ade1bd0b18e3ec5b2b788eeac630e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5658d7c5032ade1bd0b18e3ec5b2b788eeac630e/tokio/src/runtime/runtime.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12 | /// use tokio::runtime::Runtime;
///
/// fn main() {
/// let runtime = Runtime::new().unwrap();
///
/// runtime.block_on(async move {
/// let inner_runtime = Runtime::new().unwrap();
/// // ...
/// inner_runtime.shutdown_background();
/// });
/// }
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 5658d7c5032ade1bd0b18e3ec5b2b788eeac630e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5658d7c5032ade1bd0b18e3ec5b2b788eeac630e/tokio/src/runtime/runtime.rs | 441 | 495 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:13 | }
}
impl std::panic::UnwindSafe for Runtime {}
impl std::panic::RefUnwindSafe for Runtime {}
cfg_metrics! {
impl Runtime {
/// TODO
pub fn metrics(&self) -> crate::runtime::RuntimeMetrics {
self.handle.metrics()
}
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 5658d7c5032ade1bd0b18e3ec5b2b788eeac630e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5658d7c5032ade1bd0b18e3ec5b2b788eeac630e/tokio/src/runtime/runtime.rs | 481 | 495 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:3 | /// current runtime. Whenever you are inside the runtime context, methods such
/// as [`tokio::spawn`] will use the runtime whose context you are inside.
///
/// [timer]: crate::time
/// [mod]: index.html
/// [`new`]: method@Self::new
/// [`Builder`]: struct@Builder
/// [`Handle`]: struct@Handle
/// [`tokio::spawn`]: c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | ed4f766c98d4b693160370d4021e76f56dc2d82e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ed4f766c98d4b693160370d4021e76f56dc2d82e/tokio/src/runtime/runtime.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:4 | /// The runtime scheduler is either a multi-thread or a current-thread executor.
#[derive(Debug)]
pub(super) enum Scheduler {
/// Execute all tasks on the current-thread.
CurrentThread(CurrentThread),
/// Execute tasks across multiple threads.
#[cfg(all(feature = "rt-multi-thread", not(target_os = "was... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | ed4f766c98d4b693160370d4021e76f56dc2d82e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ed4f766c98d4b693160370d4021e76f56dc2d82e/tokio/src/runtime/runtime.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:8 | ///
/// Note that the future required by this function does not run as a
/// worker. The expectation is that other tasks are spawned by the future here.
/// Awaiting on other futures from the future provided here will not
/// perform as fast as those spawned as workers.
///
/// # Multi thread sc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | ed4f766c98d4b693160370d4021e76f56dc2d82e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ed4f766c98d4b693160370d4021e76f56dc2d82e/tokio/src/runtime/runtime.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:9 | /// println!("hello");
/// });
/// ```
///
/// [handle]: fn@Handle::block_on
#[track_caller]
pub fn block_on<F: Future>(&self, future: F) -> F::Output {
#[cfg(all(
tokio_unstable,
tokio_taskdump,
feature = "rt",
target_os = "linux",
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | ed4f766c98d4b693160370d4021e76f56dc2d82e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ed4f766c98d4b693160370d4021e76f56dc2d82e/tokio/src/runtime/runtime.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12 | ///
/// fn main() {
/// let runtime = Runtime::new().unwrap();
///
/// runtime.block_on(async move {
/// let inner_runtime = Runtime::new().unwrap();
/// // ...
/// inner_runtime.shutdown_background();
/// });
/// }
/// ```
pub fn shutdown_backgr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | ed4f766c98d4b693160370d4021e76f56dc2d82e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ed4f766c98d4b693160370d4021e76f56dc2d82e/tokio/src/runtime/runtime.rs | 441 | 494 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:13 | }
impl std::panic::UnwindSafe for Runtime {}
impl std::panic::RefUnwindSafe for Runtime {}
cfg_metrics! {
impl Runtime {
/// TODO
pub fn metrics(&self) -> crate::runtime::RuntimeMetrics {
self.handle.metrics()
}
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | ed4f766c98d4b693160370d4021e76f56dc2d82e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ed4f766c98d4b693160370d4021e76f56dc2d82e/tokio/src/runtime/runtime.rs | 481 | 494 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12 | ///
/// fn main() {
/// let runtime = Runtime::new().unwrap();
///
/// runtime.block_on(async move {
/// let inner_runtime = Runtime::new().unwrap();
/// // ...
/// inner_runtime.shutdown_background();
/// });
/// }
/// ```
pub fn shutdown_backgr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/runtime.rs | 441 | 490 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:13 | }
cfg_metrics! {
impl Runtime {
/// TODO
pub fn metrics(&self) -> crate::runtime::RuntimeMetrics {
self.handle.metrics()
}
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/runtime.rs | 481 | 490 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12 | ///
/// fn main() {
/// let runtime = Runtime::new().unwrap();
///
/// runtime.block_on(async move {
/// let inner_runtime = Runtime::new().unwrap();
/// // ...
/// inner_runtime.shutdown_background();
/// });
/// }
/// ```
pub fn shutdown_backgr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 3d64a06600179f85c3f20022733bb0c97e3367b5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3d64a06600179f85c3f20022733bb0c97e3367b5/tokio/src/runtime/runtime.rs | 441 | 490 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:9 | /// });
/// ```
///
/// [handle]: fn@Handle::block_on
#[track_caller]
pub fn block_on<F: Future>(&self, future: F) -> F::Output {
#[cfg(all(
tokio_unstable,
tokio_taskdump,
feature = "rt",
target_os = "linux",
any(target_arch = "aar... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/src/runtime/runtime.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12 | /// fn main() {
/// let runtime = Runtime::new().unwrap();
///
/// runtime.block_on(async move {
/// let inner_runtime = Runtime::new().unwrap();
/// // ...
/// inner_runtime.shutdown_background();
/// });
/// }
/// ```
pub fn shutdown_background(sel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/src/runtime/runtime.rs | 441 | 489 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:3 | /// current runtime. Whenever you are inside the runtime context, methods such
/// as [`tokio::spawn`] will use the runtime whose context you are inside.
///
/// [timer]: crate::time
/// [mod]: index.html
/// [`new`]: method@Self::new
/// [`Builder`]: struct@Builder
/// [`Handle`]: struct@Handle
/// [`tokio::spawn`]: c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 4165601b1bbaa7c29cbfb319fe75a9adddf4085e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4165601b1bbaa7c29cbfb319fe75a9adddf4085e/tokio/src/runtime/runtime.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:4 | /// The runtime scheduler is either a multi-thread or a current-thread executor.
#[derive(Debug)]
pub(super) enum Scheduler {
/// Execute all tasks on the current-thread.
CurrentThread(CurrentThread),
/// Execute tasks across multiple threads.
#[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))]
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 4165601b1bbaa7c29cbfb319fe75a9adddf4085e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4165601b1bbaa7c29cbfb319fe75a9adddf4085e/tokio/src/runtime/runtime.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:9 | /// });
/// ```
///
/// [handle]: fn@Handle::block_on
#[track_caller]
pub fn block_on<F: Future>(&self, future: F) -> F::Output {
#[cfg(all(
tokio_unstable,
tokio_taskdump,
feature = "rt",
target_os = "linux",
any(target_arch = "aar... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 4165601b1bbaa7c29cbfb319fe75a9adddf4085e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4165601b1bbaa7c29cbfb319fe75a9adddf4085e/tokio/src/runtime/runtime.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12 | /// fn main() {
/// let runtime = Runtime::new().unwrap();
///
/// runtime.block_on(async move {
/// let inner_runtime = Runtime::new().unwrap();
/// // ...
/// inner_runtime.shutdown_background();
/// });
/// }
/// ```
pub fn shutdown_background(sel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 4165601b1bbaa7c29cbfb319fe75a9adddf4085e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4165601b1bbaa7c29cbfb319fe75a9adddf4085e/tokio/src/runtime/runtime.rs | 441 | 489 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:3 | /// [mod]: index.html
/// [`new`]: method@Self::new
/// [`Builder`]: struct@Builder
/// [`Handle`]: struct@Handle
/// [`tokio::spawn`]: crate::spawn
/// [`Arc::try_unwrap`]: std::sync::Arc::try_unwrap
/// [Arc]: std::sync::Arc
/// [`shutdown_background`]: method@Runtime::shutdown_background
/// [`shutdown_timeout`]: me... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 91ad76c00c624ed607cf7fa53a6cc40f83f08159 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/91ad76c00c624ed607cf7fa53a6cc40f83f08159/tokio/src/runtime/runtime.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:4 | #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))]
MultiThread(MultiThread),
}
impl Runtime {
pub(super) fn from_parts(
scheduler: Scheduler,
handle: Handle,
blocking_pool: BlockingPool,
) -> Runtime {
Runtime {
scheduler,
handle,
b... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 91ad76c00c624ed607cf7fa53a6cc40f83f08159 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/91ad76c00c624ed607cf7fa53a6cc40f83f08159/tokio/src/runtime/runtime.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:6 | /// thread pool. The thread pool is then responsible for polling the future
/// until it completes.
///
/// The provided future will start running in the background immediately
/// when `spawn` is called, even if you don't await the returned
/// `JoinHandle`.
///
/// See [module level][mod] ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 91ad76c00c624ed607cf7fa53a6cc40f83f08159 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/91ad76c00c624ed607cf7fa53a6cc40f83f08159/tokio/src/runtime/runtime.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:8 | ///
/// # Current thread scheduler
///
/// When the current thread scheduler is enabled `block_on`
/// can be called concurrently from multiple threads. The first call
/// will take ownership of the io and timer drivers. This means
/// other threads which do not own the drivers will hook into th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 91ad76c00c624ed607cf7fa53a6cc40f83f08159 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/91ad76c00c624ed607cf7fa53a6cc40f83f08159/tokio/src/runtime/runtime.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:9 | any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
))]
let future = super::task::trace::Trace::root(future);
#[cfg(all(tokio_unstable, feature = "tracing"))]
let future = crate::util::trace::task(
future,
"block_on",
None,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 91ad76c00c624ed607cf7fa53a6cc40f83f08159 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/91ad76c00c624ed607cf7fa53a6cc40f83f08159/tokio/src/runtime/runtime.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:11 | /// runtime.shutdown_timeout(Duration::from_millis(100));
/// }
/// ```
pub fn shutdown_timeout(mut self, duration: Duration) {
// Wakeup and shutdown all the worker threads
self.handle.inner.shutdown();
self.blocking_pool.shutdown(Some(duration));
}
/// Shuts down the ru... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 91ad76c00c624ed607cf7fa53a6cc40f83f08159 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/91ad76c00c624ed607cf7fa53a6cc40f83f08159/tokio/src/runtime/runtime.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12 | }
#[allow(clippy::single_match)] // there are comments in the error branch, so we don't want if-let
impl Drop for Runtime {
fn drop(&mut self) {
match &mut self.scheduler {
Scheduler::CurrentThread(current_thread) => {
// This ensures that tasks spawned on the current-thread
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 91ad76c00c624ed607cf7fa53a6cc40f83f08159 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/91ad76c00c624ed607cf7fa53a6cc40f83f08159/tokio/src/runtime/runtime.rs | 441 | 470 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:2 | /// `shutdown_background` and `shutdown_timeout` can be used if waiting forever
/// is undesired. When the timeout is reached, spawned work that did not stop
/// in time and threads running it are leaked. The work continues to run until
/// one of the stopping conditions is fulfilled, but the thread initiating the
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 660eac71f0ac7274dc3ba6dd92df9ff2ea61be9f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/660eac71f0ac7274dc3ba6dd92df9ff2ea61be9f/tokio/src/runtime/runtime.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:3 | #[non_exhaustive]
pub enum RuntimeFlavor {
/// The flavor that executes all tasks on the current thread.
CurrentThread,
/// The flavor that executes tasks across multiple threads.
MultiThread,
}
/// The runtime scheduler is either a multi-thread or a current-thread executor.
#[derive(Debug)]
pub(super)... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 660eac71f0ac7274dc3ba6dd92df9ff2ea61be9f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/660eac71f0ac7274dc3ba6dd92df9ff2ea61be9f/tokio/src/runtime/runtime.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:6 | /// ```
#[track_caller]
pub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
where
F: Future + Send + 'static,
F::Output: Send + 'static,
{
self.handle.spawn(future)
}
/// Runs the provided function on an executor dedicated to blocking operations.
///
/// #... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 660eac71f0ac7274dc3ba6dd92df9ff2ea61be9f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/660eac71f0ac7274dc3ba6dd92df9ff2ea61be9f/tokio/src/runtime/runtime.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:8 | ///
/// // Execute the future, blocking the current thread until completion
/// rt.block_on(async {
/// println!("hello");
/// });
/// ```
///
/// [handle]: fn@Handle::block_on
#[track_caller]
pub fn block_on<F: Future>(&self, future: F) -> F::Output {
#[cfg(all(
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 660eac71f0ac7274dc3ba6dd92df9ff2ea61be9f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/660eac71f0ac7274dc3ba6dd92df9ff2ea61be9f/tokio/src/runtime/runtime.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:11 | /// use tokio::runtime::Runtime;
///
/// fn main() {
/// let runtime = Runtime::new().unwrap();
///
/// runtime.block_on(async move {
/// let inner_runtime = Runtime::new().unwrap();
/// // ...
/// inner_runtime.shutdown_background();
/// });
/// }
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 660eac71f0ac7274dc3ba6dd92df9ff2ea61be9f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/660eac71f0ac7274dc3ba6dd92df9ff2ea61be9f/tokio/src/runtime/runtime.rs | 401 | 445 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:8 | ///
/// // Execute the future, blocking the current thread until completion
/// rt.block_on(async {
/// println!("hello");
/// });
/// ```
///
/// [handle]: fn@Handle::block_on
#[track_caller]
pub fn block_on<F: Future>(&self, future: F) -> F::Output {
#[cfg(all(tokio_uns... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 2298679af4f7b48ac181b54a3c526391d47c94b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2298679af4f7b48ac181b54a3c526391d47c94b1/tokio/src/runtime/runtime.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:10 | /// runtime.block_on(async move {
/// task::spawn_blocking(move || {
/// thread::sleep(Duration::from_secs(10_000));
/// });
/// });
///
/// runtime.shutdown_timeout(Duration::from_millis(100));
/// }
/// ```
pub fn shutdown_timeout(mut self, duratio... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 2298679af4f7b48ac181b54a3c526391d47c94b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2298679af4f7b48ac181b54a3c526391d47c94b1/tokio/src/runtime/runtime.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:11 | /// });
/// }
/// ```
pub fn shutdown_background(self) {
self.shutdown_timeout(Duration::from_nanos(0))
}
}
#[allow(clippy::single_match)] // there are comments in the error branch, so we don't want if-let
impl Drop for Runtime {
fn drop(&mut self) {
match &mut self.scheduler {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 2298679af4f7b48ac181b54a3c526391d47c94b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2298679af4f7b48ac181b54a3c526391d47c94b1/tokio/src/runtime/runtime.rs | 401 | 436 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:6 | /// ```
#[track_caller]
pub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
where
F: Future + Send + 'static,
F::Output: Send + 'static,
{
self.handle.spawn(future)
}
/// Runs the provided function on an executor dedicated to blocking operations.
///
/// #... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 061325ba7ea952c78b23abe685e40a3aac132a2b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/061325ba7ea952c78b23abe685e40a3aac132a2b/tokio/src/runtime/runtime.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:7 | /// which the future spawns internally will be executed on the runtime.
///
/// # Multi thread scheduler
///
/// When the multi thread scheduler is used this will allow futures
/// to run within the io driver and timer context of the overall runtime.
///
/// Any spawned tasks will continue r... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 061325ba7ea952c78b23abe685e40a3aac132a2b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/061325ba7ea952c78b23abe685e40a3aac132a2b/tokio/src/runtime/runtime.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:8 | /// [handle]: fn@Handle::block_on
#[track_caller]
pub fn block_on<F: Future>(&self, future: F) -> F::Output {
#[cfg(all(tokio_unstable, feature = "tracing"))]
let future = crate::util::trace::task(
future,
"block_on",
None,
crate::runtime::task::Id... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 061325ba7ea952c78b23abe685e40a3aac132a2b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/061325ba7ea952c78b23abe685e40a3aac132a2b/tokio/src/runtime/runtime.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:10 | /// }
/// ```
pub fn shutdown_timeout(mut self, duration: Duration) {
// Wakeup and shutdown all the worker threads
self.handle.inner.shutdown();
self.blocking_pool.shutdown(Some(duration));
}
/// Shuts down the runtime, without waiting for any spawned work to stop.
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 061325ba7ea952c78b23abe685e40a3aac132a2b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/061325ba7ea952c78b23abe685e40a3aac132a2b/tokio/src/runtime/runtime.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:11 | #[allow(clippy::single_match)] // there are comments in the error branch, so we don't want if-let
impl Drop for Runtime {
fn drop(&mut self) {
match &mut self.scheduler {
Scheduler::CurrentThread(current_thread) => {
// This ensures that tasks spawned on the current-thread
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 061325ba7ea952c78b23abe685e40a3aac132a2b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/061325ba7ea952c78b23abe685e40a3aac132a2b/tokio/src/runtime/runtime.rs | 401 | 429 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:1 | use crate::runtime::blocking::BlockingPool;
use crate::runtime::scheduler::CurrentThread;
use crate::runtime::{context, EnterGuard, Handle};
use crate::task::JoinHandle;
use std::future::Future;
use std::time::Duration;
cfg_rt_multi_thread! {
use crate::runtime::Builder;
use crate::runtime::scheduler::MultiTh... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 06f1a601bb05b1aba9f95020a7fa7572899c588f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06f1a601bb05b1aba9f95020a7fa7572899c588f/tokio/src/runtime/runtime.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:2 | /// in a `Arc`. Most fn take `&self` to allow you to call them concurrently
/// across multiple threads.
///
/// Calls to `shutdown` and `shutdown_timeout` require exclusive ownership of
/// the runtime type and this can be achieved via `Arc::try_unwrap` when only
/// one strong count reference is left over.
///
/// [t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 06f1a601bb05b1aba9f95020a7fa7572899c588f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06f1a601bb05b1aba9f95020a7fa7572899c588f/tokio/src/runtime/runtime.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:3 | /// Execute tasks across multiple threads.
#[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))]
MultiThread(MultiThread),
}
impl Runtime {
pub(super) fn from_parts(
scheduler: Scheduler,
handle: Handle,
blocking_pool: BlockingPool,
) -> Runtime {
Runtime {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 06f1a601bb05b1aba9f95020a7fa7572899c588f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06f1a601bb05b1aba9f95020a7fa7572899c588f/tokio/src/runtime/runtime.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:5 | ///
/// This spawns the given future onto the runtime's executor, usually a
/// thread pool. The thread pool is then responsible for polling the future
/// until it completes.
///
/// The provided future will start running in the background immediately
/// when `spawn` is called, even if you don... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 06f1a601bb05b1aba9f95020a7fa7572899c588f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06f1a601bb05b1aba9f95020a7fa7572899c588f/tokio/src/runtime/runtime.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:7 | /// will take ownership of the io and timer drivers. This means
/// other threads which do not own the drivers will hook into that one.
/// When the first `block_on` completes, other threads will be able to
/// "steal" the driver to allow continued execution of their futures.
///
/// Any spawned tas... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 06f1a601bb05b1aba9f95020a7fa7572899c588f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06f1a601bb05b1aba9f95020a7fa7572899c588f/tokio/src/runtime/runtime.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:10 | self.handle.inner.shutdown();
self.blocking_pool.shutdown(Some(duration));
}
/// Shuts down the runtime, without waiting for any spawned tasks to shutdown.
///
/// This can be useful if you want to drop a runtime from within another runtime.
/// Normally, dropping a runtime will block indef... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 06f1a601bb05b1aba9f95020a7fa7572899c588f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06f1a601bb05b1aba9f95020a7fa7572899c588f/tokio/src/runtime/runtime.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:11 | // This ensures that tasks spawned on the current-thread
// runtime are dropped inside the runtime's context.
let _guard = context::try_set_current(&self.handle.inner);
current_thread.shutdown(&self.handle.inner);
}
#[cfg(all(feature = "rt-multi-th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 06f1a601bb05b1aba9f95020a7fa7572899c588f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06f1a601bb05b1aba9f95020a7fa7572899c588f/tokio/src/runtime/runtime.rs | 401 | 423 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:5 | ///
/// This spawns the given future onto the runtime's executor, usually a
/// thread pool. The thread pool is then responsible for polling the future
/// until it completes.
///
/// You do not have to `.await` the returned `JoinHandle` to make the
/// provided future start execution. It will s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 86ffabe2af69f2440be26d153fd692689c9947fb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/86ffabe2af69f2440be26d153fd692689c9947fb/tokio/src/runtime/runtime.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:5 | /// until it completes.
///
/// You do not have to `.await` the returned `JoinHandle` to make the
/// provided future start execution. It will start running in the
/// background immediately when `spawn` is called.
///
/// See [module level][mod] documentation for more details.
///
/// [... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | b2f5dbea4703be0c97150b91d3b2c46f29f1a0bf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2f5dbea4703be0c97150b91d3b2c46f29f1a0bf/tokio/src/runtime/runtime.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:7 | /// "steal" the driver to allow continued execution of their futures.
///
/// Any spawned tasks will be suspended after `block_on` returns. Calling
/// `block_on` again will resume previously spawned tasks.
///
/// # Panics
///
/// This function panics if the provided future panics, or if ca... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | b2f5dbea4703be0c97150b91d3b2c46f29f1a0bf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2f5dbea4703be0c97150b91d3b2c46f29f1a0bf/tokio/src/runtime/runtime.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:10 | /// Shuts down the runtime, without waiting for any spawned tasks to shutdown.
///
/// This can be useful if you want to drop a runtime from within another runtime.
/// Normally, dropping a runtime will block indefinitely for spawned blocking tasks
/// to complete, which would normally not be permitted ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | b2f5dbea4703be0c97150b91d3b2c46f29f1a0bf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2f5dbea4703be0c97150b91d3b2c46f29f1a0bf/tokio/src/runtime/runtime.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:11 | current_thread.shutdown(&self.handle.inner);
}
#[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))]
Scheduler::MultiThread(multi_thread) => {
// The threaded scheduler drops its tasks on its worker threads, which is
// already in the runtime's con... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | b2f5dbea4703be0c97150b91d3b2c46f29f1a0bf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2f5dbea4703be0c97150b91d3b2c46f29f1a0bf/tokio/src/runtime/runtime.rs | 401 | 420 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:7 | /// "steal" the driver to allow continued execution of their futures.
///
/// Any spawned tasks will be suspended after `block_on` returns. Calling
/// `block_on` again will resume previously spawned tasks.
///
/// # Panics
///
/// This function panics if the provided future panics, or if ca... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 26791a62bce6287e3a7274a726e690f98a29a34b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/26791a62bce6287e3a7274a726e690f98a29a34b/tokio/src/runtime/runtime.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:10 | /// Shuts down the runtime, without waiting for any spawned tasks to shutdown.
///
/// This can be useful if you want to drop a runtime from within another runtime.
/// Normally, dropping a runtime will block indefinitely for spawned blocking tasks
/// to complete, which would normally not be permitted ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 26791a62bce6287e3a7274a726e690f98a29a34b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/26791a62bce6287e3a7274a726e690f98a29a34b/tokio/src/runtime/runtime.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/runtime.rs:11 | Some(guard) => current_thread.set_context_guard(guard),
None => {
// The context thread-local has already been destroyed.
//
// We don't set the guard in this case. Calls to tokio::spawn in task
// destru... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/runtime.rs | MIT | 26791a62bce6287e3a7274a726e690f98a29a34b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/26791a62bce6287e3a7274a726e690f98a29a34b/tokio/src/runtime/runtime.rs | 401 | 426 |
tokio-rs/tokio:tokio/src/runtime/scheduler/block_in_place.rs:1 | use crate::runtime::scheduler;
#[track_caller]
pub(crate) fn block_in_place<F, R>(f: F) -> R
where
F: FnOnce() -> R,
{
scheduler::multi_thread::block_in_place(f)
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/scheduler/block_in_place.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/block_in_place.rs | 1 | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.