Struct vertx_rust::vertx::RUNTIME [−][src]
Methods from Deref<Target = Runtime>
pub fn handle(&self) -> &Handle
[src]
Return a handle to the runtime’s spawner.
The returned handle can be used to spawn tasks that run on this runtime, and can
be cloned to allow moving the Handle
to other threads.
Examples
use tokio::runtime::Runtime; let rt = Runtime::new() .unwrap(); let handle = rt.handle(); // Use the handle...
pub fn spawn<F>(&self, future: F) -> JoinHandle<<F as Future>::Output> where
F: Future + Send + 'static,
<F as Future>::Output: Send,
<F as Future>::Output: 'static,
[src]
F: Future + Send + 'static,
<F as Future>::Output: Send,
<F as Future>::Output: 'static,
Spawn a future onto the Tokio runtime.
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.
See module level documentation for more details.
Examples
use tokio::runtime::Runtime; // Create the runtime let rt = Runtime::new().unwrap(); // Spawn a future onto the runtime rt.spawn(async { println!("now running on a worker thread"); });
pub fn spawn_blocking<F, R>(&self, func: F) -> JoinHandle<R> where
R: Send + 'static,
F: FnOnce() -> R + Send + 'static,
[src]
R: Send + 'static,
F: FnOnce() -> R + Send + 'static,
Run the provided function on an executor dedicated to blocking operations.
Examples
use tokio::runtime::Runtime; // Create the runtime let rt = Runtime::new().unwrap(); // Spawn a blocking function onto the runtime rt.spawn_blocking(|| { println!("now running on a worker thread"); });
pub fn block_on<F>(&self, future: F) -> <F as Future>::Output where
F: Future,
[src]
F: Future,
Run a future to completion on the Tokio runtime. This is the runtime’s entry point.
This runs the given future on the runtime, blocking until it is complete, and yielding its resolved result. Any tasks or timers 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.
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 that one.
When the first block_on
completes, other threads will be able to
“steal” the driver to allow continued execution of their futures.
Panics
This function panics if the provided future panics, or if called within an asynchronous execution context.
Examples
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"); });
pub fn enter(&self) -> EnterGuard<'_>
[src]
Enter the runtime context.
This allows you to construct types that must have an executor
available on creation such as Sleep
or TcpStream
. It will
also allow you to call methods such as tokio::spawn
.
Example
use tokio::runtime::Runtime; fn function_that_spawns(msg: String) { // Had we not used `rt.enter` below, this would panic. tokio::spawn(async move { println!("{}", msg); }); } fn main() { let rt = Runtime::new().unwrap(); let s = "Hello World!".to_string(); // By entering the context, we tie `tokio::spawn` to this executor. let _guard = rt.enter(); function_that_spawns(s); }
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for RUNTIME
impl Send for RUNTIME
impl Sync for RUNTIME
impl Unpin for RUNTIME
impl UnwindSafe for RUNTIME
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,