pub struct Runtime { /* private fields */ }Expand description
See Runtime
Implementations§
Methods from Deref<Target = Runtime>§
Sourcepub fn driver_type(&self) -> DriverType
pub fn driver_type(&self) -> DriverType
The current driver type.
Sourcepub fn enter<T, F>(&self, f: F) -> Twhere
F: FnOnce() -> T,
pub fn enter<T, F>(&self, f: F) -> Twhere
F: FnOnce() -> T,
Set this runtime as current runtime, and perform a function in the current scope.
Sourcepub unsafe fn spawn_unchecked<F>(
&self,
future: F,
) -> Task<<F as Future>::Output>where
F: Future,
pub unsafe fn spawn_unchecked<F>(
&self,
future: F,
) -> Task<<F as Future>::Output>where
F: Future,
Sourcepub fn run(&self) -> bool
pub fn run(&self) -> bool
Low level API to control the runtime.
Run the scheduled tasks.
The return value indicates whether there are still tasks in the queue.
Sourcepub fn waker(&self) -> Waker
pub fn waker(&self) -> Waker
Low level API to control the runtime.
Create a waker that always notifies the runtime when woken.
Sourcepub fn opt_waker(&self) -> Arc<OptWaker>
pub fn opt_waker(&self) -> Arc<OptWaker>
Low level API to control the runtime.
Create an optimized waker that only notifies the runtime when woken
from another thread, or when notify-always is enabled.
Sourcepub fn block_on<F>(&self, future: F) -> <F as Future>::Outputwhere
F: Future,
pub fn block_on<F>(&self, future: F) -> <F as Future>::Outputwhere
F: Future,
Block on the future till it completes.
Sourcepub fn spawn<F>(
&self,
future: F,
) -> Task<Result<<F as Future>::Output, Box<dyn Any + Send>>>where
F: Future + 'static,
pub fn spawn<F>(
&self,
future: F,
) -> Task<Result<<F as Future>::Output, Box<dyn Any + Send>>>where
F: Future + 'static,
Spawns a new asynchronous task, returning a Task for it.
Spawning a task enables the task to execute concurrently to other tasks. There is no guarantee that a spawned task will execute to completion.
Sourcepub fn spawn_blocking<T>(
&self,
f: impl FnOnce() -> T + Send + 'static,
) -> Task<Result<T, Box<dyn Any + Send>>>where
T: Send + 'static,
pub fn spawn_blocking<T>(
&self,
f: impl FnOnce() -> T + Send + 'static,
) -> Task<Result<T, Box<dyn Any + Send>>>where
T: Send + 'static,
Spawns a blocking task in a new thread, and wait for it.
The task will not be cancelled even if the future is dropped.
Sourcepub fn attach(&self, fd: i32) -> Result<(), Error>
pub fn attach(&self, fd: i32) -> Result<(), Error>
Attach a raw file descriptor/handle/socket to the runtime.
You only need this when authoring your own high-level APIs. High-level resources in this crate are attached automatically.
Sourcepub fn current_timeout(&self) -> Option<Duration>
pub fn current_timeout(&self) -> Option<Duration>
Low level API to control the runtime.
Get the timeout value to be passed to Proactor::poll.
Sourcepub fn poll(&self)
pub fn poll(&self)
Low level API to control the runtime.
Poll the inner proactor. It is equal to calling Runtime::poll_with
with Runtime::current_timeout.
Sourcepub fn poll_with(&self, timeout: Option<Duration>)
pub fn poll_with(&self, timeout: Option<Duration>)
Low level API to control the runtime.
Poll the inner proactor with a custom timeout.
Sourcepub fn register_personality(&self) -> Result<u16, Error>
pub fn register_personality(&self) -> Result<u16, Error>
Register the personality for the runtime.
This is only supported on io-uring driver, and will return an
Unsupported io error on all other drivers.
The returned personality can be used with FutureExt::with_personality
if the future-combinator feature is turned on.
Sourcepub fn unregister_personality(&self, personality: u16) -> Result<(), Error>
pub fn unregister_personality(&self, personality: u16) -> Result<(), Error>
Unregister the given personality for the runtime.
This is only supported on io-uring driver, and will return an
Unsupported io error on all other drivers.