pub struct WaiterThread { /* private fields */ }Expand description
Permanently-attached waiter thread + request channel.
Cheap to construct (one mpsc::channel + one thread::spawn).
Joined cleanly on Drop: the channel sender is dropped, the
thread’s recv() returns Err, the loop exits, and the join
handle is consumed.
Every request that is in flight or still queued when Drop runs is
resolved with Error::Cancelled before the thread exits.
BackendWaitFuture borrows nothing from this type, so a caller may
hold one across the drop; without that resolution its await would
pend forever.
Per-instance ownership is supported, but the usual shape is a per-backend-kind static singleton in each backend’s waiter module. See module-level docs.
Implementations§
Source§impl WaiterThread
impl WaiterThread
Sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Spawn a new waiter thread. name is appended to
"wgpu-interop-wait-" for the thread name visible to debuggers
and ps -L / Process Explorer. Pick a stable
backend-identifying string ("vulkan", "wgpu", "d3d12",
"metal", "opencl", …).
Sourcepub fn enqueue(
&self,
slice_fn: SliceFn,
deadline: Option<Instant>,
) -> BackendWaitFuture ⓘ
pub fn enqueue( &self, slice_fn: SliceFn, deadline: Option<Instant>, ) -> BackendWaitFuture ⓘ
Enqueue a wait request. Returns a BackendWaitFuture the
executor can .await; Drop of the future signals
cancellation to the waiter thread.
deadline = None means “wait forever” — the slice loop never
transitions to Err(Timeout) and only exits on
Signaled / Failed / cancelled.