pub struct AsyncRuntime { /* private fields */ }Expand description
Manages the Tokio async runtime for a plugin
Implementations§
Source§impl AsyncRuntime
impl AsyncRuntime
Sourcepub fn new(config: RuntimeConfig) -> PluginResult<Self>
pub fn new(config: RuntimeConfig) -> PluginResult<Self>
Create a new async runtime with the given configuration
Sourcepub fn with_defaults() -> PluginResult<Self>
pub fn with_defaults() -> PluginResult<Self>
Create a runtime with default configuration
Sourcepub fn config(&self) -> &RuntimeConfig
pub fn config(&self) -> &RuntimeConfig
Get the runtime configuration
Sourcepub fn shutdown_signal(&self) -> ShutdownSignal
pub fn shutdown_signal(&self) -> ShutdownSignal
Get a shutdown signal that can be used to detect shutdown
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 from a sync context
This is the primary method for bridging sync FFI calls to async handlers.
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
Sourcepub fn spawn_blocking<F, R>(&self, func: F) -> JoinHandle<R>
pub fn spawn_blocking<F, R>(&self, func: F) -> JoinHandle<R>
Spawn a blocking task
Sourcepub fn shutdown(&self, _timeout: Duration) -> PluginResult<()>
pub fn shutdown(&self, _timeout: Duration) -> PluginResult<()>
Initiate graceful shutdown
This signals all tasks to stop. The runtime will complete shutdown when dropped. We don’t unconditionally sleep for the timeout since most plugins have no long-running background tasks.
Sourcepub fn is_shutting_down(&self) -> bool
pub fn is_shutting_down(&self) -> bool
Check if shutdown has been triggered
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AsyncRuntime
impl !RefUnwindSafe for AsyncRuntime
impl Send for AsyncRuntime
impl Sync for AsyncRuntime
impl Unpin 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