• Home
  • Raw
  • Download

Lines Matching full:runtime

1 use crate::runtime::blocking::BlockingPool;
2 use crate::runtime::scheduler::CurrentThread;
3 use crate::runtime::{context, EnterGuard, Handle};
10 use crate::runtime::Builder;
11 use crate::runtime::scheduler::MultiThread;
14 /// The Tokio runtime.
16 /// The runtime provides an I/O driver, task scheduler, [timer], and
19 /// Instances of `Runtime` can be created using [`new`], or [`Builder`].
27 /// Shutting down the runtime is done by dropping the value. The current
40 /// The Tokio runtime implements `Sync` and `Send` to allow you to wrap it
45 /// the runtime type and this can be achieved via `Arc::try_unwrap` when only
53 pub struct Runtime { struct
57 /// Handle to runtime, also contains driver handles
64 /// The flavor of a `Runtime`. argument
66 /// This is the return type for [`Handle::runtime_flavor`](crate::runtime::Handle::runtime_flavor()…
76 /// The runtime scheduler is either a multi-thread or a current-thread executor.
87 impl Runtime { impl
92 ) -> Runtime { in from_parts() argument
93 Runtime { in from_parts()
101 /// Creates a new runtime instance with default configuration values.
108 /// configuration is necessary, the [runtime builder] may be used.
114 /// Creating a new `Runtime` with default configuration values.
117 /// use tokio::runtime::Runtime;
119 /// let rt = Runtime::new()
122 /// // Use the runtime...
128 /// [runtime builder]: crate::runtime::Builder
131 pub fn new() -> std::io::Result<Runtime> {
136 /// Returns a handle to the runtime's spawner.
138 /// The returned handle can be used to spawn tasks that run on this runtime, and can
141 /// Calling [`Handle::block_on`] on a handle to a `current_thread` runtime is error-prone.
147 /// use tokio::runtime::Runtime;
149 /// let rt = Runtime::new()
160 /// Spawns a future onto the Tokio runtime.
162 /// This spawns the given future onto the runtime's executor, usually a
177 /// use tokio::runtime::Runtime;
180 /// // Create the runtime
181 /// let rt = Runtime::new().unwrap();
183 /// // Spawn a future onto the runtime
203 /// use tokio::runtime::Runtime;
206 /// // Create the runtime
207 /// let rt = Runtime::new().unwrap();
209 /// // Spawn a blocking function onto the runtime
223 /// Runs a future to completion on the Tokio runtime. This is the
224 /// runtime's entry point.
228 /// which the future spawns internally will be executed on the runtime.
233 /// to run within the io driver and timer context of the overall runtime.
257 /// use tokio::runtime::Runtime;
259 /// // Create the runtime
260 /// let rt = Runtime::new().unwrap();
276 crate::runtime::task::Id::next().as_u64(), in block_on()
288 /// Enters the runtime context.
301 /// use tokio::runtime::Runtime;
311 /// let rt = Runtime::new().unwrap();
324 /// Shuts down the runtime, waiting for at most `duration` for all spawned
327 /// Usually, dropping a `Runtime` handle is sufficient as tasks are able to
328 /// shutdown in a timely fashion. However, dropping a `Runtime` will wait
330 /// blocking task has been spawned, which can block dropping `Runtime`.
341 /// use tokio::runtime::Runtime;
348 /// let runtime = Runtime::new().unwrap();
350 /// runtime.block_on(async move {
356 /// runtime.shutdown_timeout(Duration::from_millis(100));
365 /// Shuts down the runtime, without waiting for any spawned tasks to shutdown.
367 /// This can be useful if you want to drop a runtime from within another runtime.
368 /// Normally, dropping a runtime will block indefinitely for spawned blocking tasks
370 /// By calling `shutdown_background()`, you can drop the runtime from such a context.
379 /// use tokio::runtime::Runtime;
382 /// let runtime = Runtime::new().unwrap();
384 /// runtime.block_on(async move {
385 /// let inner_runtime = Runtime::new().unwrap();
397 impl Drop for Runtime { implementation
402 // runtime are dropped inside the runtime's context. in drop()
409 // already in the runtime's context. in drop()
417 impl Runtime { impl
419 pub fn metrics(&self) -> crate::runtime::RuntimeMetrics {