pub struct DeviceHandle<S: DeviceService> { /* private fields */ }Expand description
TODO: Docs
Implementations§
Source§impl<S: DeviceService> DeviceHandle<S>
impl<S: DeviceService> DeviceHandle<S>
pub const fn is_blocking() -> bool
pub fn insert( device_id: DeviceId, service: S, ) -> Result<Self, ServiceCreationError>
pub fn new(device_id: DeviceId) -> Self
pub fn device_id(&self) -> DeviceId
pub fn utilities(&self) -> ServerUtilitiesHandle
pub fn submit_blocking<'a, R: Send, T: FnOnce(&mut S) -> R + Send + 'a>( &self, task: T, ) -> Result<R, CallError>
pub fn submit<T: FnOnce(&mut S) + Send + 'static>(&self, task: T)
pub fn flush_queue(&self)
pub fn exclusive<R: Send, T: FnOnce() -> R + Send>( &self, task: T, ) -> Result<R, CallError>
Sourcepub fn shutdown(device_id: DeviceId)
pub fn shutdown(device_id: DeviceId)
Stops the background runner threads for device_id, blocking until they
exit. Queued tasks run before the threads stop. Live handles keep their
runner alive, so all handles for the device should be dropped first.
Only meaningful for handle implementations with background threads; a no-op otherwise.
§Scope
This is device-wide, and S is ignored. It shuts down every
DeviceService registered on device_id, across both service stages, not
only S. The type parameter selects the handle implementation to dispatch
through, nothing more.
DeviceId is not unique across runtimes either: type_id is assigned per
runtime, so distinct backends can hand out the same id. Shutting down a
device from one runtime can therefore tear down another runtime’s services
on the colliding id, and block while that runtime’s handles are still live.