pub struct AutoReleaseDispatcher { /* private fields */ }Expand description
An owned reference to a driver runtime dispatcher that auto-releases when dropped. This gives
you the best of both worlds of having an Arc<Dispatcher> and a DispatcherRef<'static>
created by Dispatcher::release:
- You can vend [
Weak]-like pointers to it that will not cause memory access errors if used after the dispatcher has shut down, like an [Arc]. - You can tie its terminal lifetime to that of the driver itself.
This is particularly useful in tests.
Implementations§
Source§impl AutoReleaseDispatcher
impl AutoReleaseDispatcher
Sourcepub unsafe fn from_raw(
dispatcher: NonNull<fdf_dispatcher>,
) -> AutoReleaseDispatcher
pub unsafe fn from_raw( dispatcher: NonNull<fdf_dispatcher>, ) -> AutoReleaseDispatcher
Creates a dispatcher ref from a raw handle.
§Safety
Caller is responsible for ensuring that the given handle is valid and not owned by any other wrapper that will free it at an arbitrary time.
Sourcepub fn as_async_dispatcher(&self) -> AsyncDispatcher
pub fn as_async_dispatcher(&self) -> AsyncDispatcher
Returns a weakened reference to this dispatcher. This weak reference will only be valid so long as the dispatcher is shutting down, after which it will no longer be usable to spawn tasks on.
Sourcepub fn as_dispatcher_ref(&self) -> DriverDispatcherRef<'_>
pub fn as_dispatcher_ref(&self) -> DriverDispatcherRef<'_>
Returns a [DispatcherRef] that references this dispatcher with a lifetime constrained by
self.
Sourcepub fn always_on_dispatcher(&self) -> AutoReleaseDispatcher
pub fn always_on_dispatcher(&self) -> AutoReleaseDispatcher
Returns the Always-On interface of this dispatcher.
Trait Implementations§
Source§impl AsAsyncDispatcherRef for AutoReleaseDispatcher
impl AsAsyncDispatcherRef for AutoReleaseDispatcher
Source§fn as_async_dispatcher_ref(&self) -> AsyncDispatcherRef<'_>
fn as_async_dispatcher_ref(&self) -> AsyncDispatcherRef<'_>
AsyncDispatcherRef corresponding to this object.§fn post_task_sync(&self, p: impl TaskCallback) -> Result<(), Status>
fn post_task_sync(&self, p: impl TaskCallback) -> Result<(), Status>
p] to be run on this dispatcher later.