Lines Matching full:runtime
1 use crate::runtime::{context, scheduler, RuntimeFlavor};
3 /// Handle to the runtime.
6 /// obtained using the [`Runtime::handle`] method.
8 /// [`Runtime::handle`]: crate::runtime::Runtime::handle()
16 use crate::runtime::task::JoinHandle;
23 /// Runtime context guard.
25 /// Returned by [`Runtime::enter`] and [`Handle::enter`], the context guard exits
26 /// the runtime context on drop.
28 /// [`Runtime::enter`]: fn@crate::runtime::Runtime::enter
37 /// Enters the runtime context. This allows you to construct types that must
55 /// Returns a `Handle` view over the currently running `Runtime`.
59 /// This will panic if called outside the context of a Tokio runtime. That means that you must
60 … /// call this on one of the threads **being run by the runtime**, or from a thread with an active
66 /// This can be used to obtain the handle of the surrounding runtime from an async
67 /// block or function running on that runtime.
71 /// # use tokio::runtime::Runtime;
73 /// # let rt = Runtime::new().unwrap();
75 /// use tokio::runtime::Handle;
80 /// println!("now running in the existing Runtime");
87 /// // This next line would cause a panic because we haven't entered the runtime
106 /// Returns a Handle view over the currently running Runtime
108 /// Returns an error if no Runtime has been started
115 /// Spawns a future onto the Tokio runtime.
117 /// This spawns the given future onto the runtime's executor, usually a
132 /// use tokio::runtime::Runtime;
135 /// // Create the runtime
136 /// let rt = Runtime::new().unwrap();
137 /// // Get a handle from this runtime
140 /// // Spawn a future onto the runtime using the handle
161 /// use tokio::runtime::Runtime;
164 /// // Create the runtime
165 /// let rt = Runtime::new().unwrap();
166 /// // Get a handle from this runtime
169 /// // Spawn a blocking function onto the runtime using the handle
183 /// Runs a future to completion on this `Handle`'s associated `Runtime`.
187 /// the future spawns internally will be executed on the runtime.
189 /// When this is used on a `current_thread` runtime, only the
190 /// [`Runtime::block_on`] method can drive the IO and timer drivers, but the
192 /// this method on a current_thread runtime, anything that relies on IO or
194 /// [`Runtime::block_on`] on the same runtime.
196 /// # If the runtime has been shut down
198 /// If the `Handle`'s associated `Runtime` has been shut down (through
199 /// [`Runtime::shutdown_background`], [`Runtime::shutdown_timeout`], or by
202 /// panic. Runtime independent futures will run as normal.
208 /// runtime that has been shut down.
213 /// use tokio::runtime::Runtime;
215 /// // Create the runtime
216 /// let rt = Runtime::new().unwrap();
218 /// // Get a handle from this runtime
230 /// use tokio::runtime::Handle;
246 /// [`Runtime::block_on`]: fn@crate::runtime::Runtime::block_on
247 /// [`Runtime::shutdown_background`]: fn@crate::runtime::Runtime::shutdown_background
248 /// [`Runtime::shutdown_timeout`]: fn@crate::runtime::Runtime::shutdown_timeout
259 // Enter the runtime context. This sets the current driver handles and in block_on()
260 // prevents blocking an existing runtime. in block_on()
276 let id = crate::runtime::task::Id::next(); in spawn_named()
282 /// Returns the flavor of the current `Runtime`.
287 /// use tokio::runtime::{Handle, RuntimeFlavor};
296 /// use tokio::runtime::{Handle, RuntimeFlavor};
313 use crate::runtime::RuntimeMetrics;
316 /// Returns a view that lets you get information about how the runtime
324 /// Error returned by `try_current` when no Runtime has been started
343 /// Returns true if the call failed because there is currently no runtime in