Skip to main content

WaiterThread

Struct WaiterThread 

Source
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

Source

pub fn new(name: &str) -> Self

Spawn a new waiter thread. name is appended to "gpu-wait-" for the thread name visible to debuggers and ps -L / Process Explorer. Pick a short, stable backend-identifying string ("vulkan", "wgpu", "d3d12", "metal", "opencl", …) — Linux truncates thread names to 15 bytes.

Source

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.

Trait Implementations§

Source§

impl Debug for WaiterThread

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for WaiterThread

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,