pub struct AsyncRuntime { /* private fields */ }Available on crate feature
tokio-comp only.Expand description
FFI-safe async runtime wrapper
This struct wraps Tokio’s Runtime and provides safe methods for:
- Creating/destroying runtime across FFI boundary
- Spawning async tasks
- Blocking on futures
- Graceful shutdown
Implementations§
Source§impl AsyncRuntime
impl AsyncRuntime
Sourcepub fn new() -> Result<Self, MarketDataError>
pub fn new() -> Result<Self, MarketDataError>
Create a new multi-threaded Tokio runtime
§Errors
Returns RuntimeError if the runtime cannot be created
Sourcepub fn block_on<F>(&self, future: F) -> F::Outputwhere
F: Future,
pub fn block_on<F>(&self, future: F) -> F::Outputwhere
F: Future,
Block on a future until it completes
Sourcepub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
pub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
Spawn a task on the runtime
Auto Trait Implementations§
impl !Freeze for AsyncRuntime
impl RefUnwindSafe for AsyncRuntime
impl Send for AsyncRuntime
impl Sync for AsyncRuntime
impl Unpin for AsyncRuntime
impl UnsafeUnpin for AsyncRuntime
impl UnwindSafe for AsyncRuntime
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
Mutably borrows from an owned value. Read more