pub struct DeviceHandle<S, I = ChannelDeviceHandle>where
I: DeviceHandleSpec,
S: ?Sized,{ /* private fields */ }Expand description
Implementations§
Source§impl<S, I> DeviceHandle<S, I>where
S: DeviceService,
I: DeviceHandleSpec,
impl<S, I> DeviceHandle<S, I>where
S: DeviceService,
I: DeviceHandleSpec,
pub fn insert( device_id: DeviceId, service: S, ) -> Result<DeviceHandle<S, I>, ServiceCreationError>
pub fn new(device_id: DeviceId) -> DeviceHandle<S, I>
Source§impl<S, I> DeviceHandle<S, I>where
S: 'static + ?Sized,
I: DeviceHandleSpec,
impl<S, I> DeviceHandle<S, I>where
S: 'static + ?Sized,
I: DeviceHandleSpec,
pub const fn is_blocking() -> bool
Sourcepub fn seen_as<T>(
self,
cast: fn(&mut (dyn Any + 'static)) -> &mut T,
) -> DeviceHandle<T, I>where
T: ?Sized,
pub fn seen_as<T>(
self,
cast: fn(&mut (dyn Any + 'static)) -> &mut T,
) -> DeviceHandle<T, I>where
T: ?Sized,
The same service, seen as T: cast turns the state this handle
already reaches into a T, once per task, on the thread that runs it.
pub fn device_id(&self) -> DeviceId
Sourcepub fn service_id(&self) -> ServiceId
pub fn service_id(&self) -> ServiceId
The service this handle reaches: its device and its concrete type, whatever it is seen as.
pub fn utilities(&self) -> Arc<dyn Any + Sync + Send> ⓘ
pub fn submit_blocking<'a, R, T>(&self, task: T) -> Result<R, CallError>
pub fn submit<T>(&self, task: T)
pub fn flush_queue(&self)
pub fn exclusive<R, T>(&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.
Trait Implementations§
Source§impl<S, I> Clone for DeviceHandle<S, I>where
I: DeviceHandleSpec,
S: ?Sized,
impl<S, I> Clone for DeviceHandle<S, I>where
I: DeviceHandleSpec,
S: ?Sized,
Source§fn clone(&self) -> DeviceHandle<S, I>
fn clone(&self) -> DeviceHandle<S, I>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more