pub struct TokioAdapter(/* private fields */);Expand description
Adapter for tokio runtime.
Methods from Deref<Target = Runtime>§
pub fn driver_type(&self) -> DriverType
pub fn driver_type(&self) -> DriverType
The current driver type.
pub 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.
pub 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.
pub 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.
pub 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.
pub fn spawn<F>(&self, future: F) -> JoinHandle<<F as Future>::Output>where
F: Future + 'static,
pub fn spawn<F>(&self, future: F) -> JoinHandle<<F as Future>::Output>where
F: Future + 'static,
Spawns a new asynchronous task, returning a [JoinHandle] 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.
pub fn spawn_blocking<T>(
&self,
f: impl FnOnce() -> T + Send + 'static,
) -> JoinHandle<T>where
T: Send + 'static,
pub fn spawn_blocking<T>(
&self,
f: impl FnOnce() -> T + Send + 'static,
) -> JoinHandle<T>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.
pub fn attach(&self, fd: *mut c_void) -> Result<(), Error>
pub fn attach(&self, fd: *mut c_void) -> 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.
pub fn submit<T>(&self, op: T) -> Submit<T>where
T: OpCode + 'static,
pub fn submit<T>(&self, op: T) -> Submit<T>where
T: OpCode + 'static,
Submit an operation to the runtime.
You only need this when authoring your own [OpCode].
pub fn submit_multi<T>(&self, op: T) -> SubmitMulti<T>where
T: OpCode + 'static,
pub fn submit_multi<T>(&self, op: T) -> SubmitMulti<T>where
T: OpCode + 'static,
Submit a multishot operation to the runtime.
You only need this when authoring your own [OpCode].
pub fn flush(&self) -> bool
pub fn flush(&self) -> bool
Flush the driver and return whether the driver has been notified.
See [Proactor::flush] for more details.
pub 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].
pub 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].
pub 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.
pub fn buffer_pool(&self) -> Result<BufferPool, Error>
pub fn buffer_pool(&self) -> Result<BufferPool, Error>
Get buffer pool of the runtime.
This will lazily initialize the pool at the first time it’s accessed, and future access to the pool will be cheap and infallible.
pub fn register_files(&self, fds: &[*mut c_void]) -> Result<(), Error>
pub fn register_files(&self, fds: &[*mut c_void]) -> Result<(), Error>
Register file descriptors for fixed-file operations.
This is only supported on io-uring driver, and will return an
Unsupported io error on all other drivers.
pub fn unregister_files(&self) -> Result<(), Error>
pub fn unregister_files(&self) -> Result<(), Error>
Unregister previously registered file descriptors.
This is only supported on io-uring driver, and will return an
Unsupported io error on all other drivers.
pub 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].
pub 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.
Trait Implementations§
Source§impl Adapter for TokioAdapter
impl Adapter for TokioAdapter
Auto Trait Implementations§
impl Freeze for TokioAdapter
impl !RefUnwindSafe for TokioAdapter
impl !Send for TokioAdapter
impl !Sync for TokioAdapter
impl Unpin for TokioAdapter
impl UnsafeUnpin for TokioAdapter
impl !UnwindSafe for TokioAdapter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more