pub struct AsyncComputeQueue {
pub submission_count: u64,
pub completed_count: u64,
/* private fields */
}Expand description
Lightweight async compute task queue.
In the CPU-stub backend, tasks complete synchronously; the API is designed to be drop-in replaceable with an actual GPU async queue once a WGPU device is available.
Fields§
§submission_count: u64Monotonically increasing submission counter.
completed_count: u64Number of tasks that have been polled and returned a result.
Implementations§
Source§impl AsyncComputeQueue
impl AsyncComputeQueue
Sourcepub fn submit(&mut self, task_id: u64, data: Vec<u8>)
pub fn submit(&mut self, task_id: u64, data: Vec<u8>)
Submit a compute task.
task_id– Caller-defined identifier for this task.data– Input payload (or pre-computed output on CPU path).
If a task with the same task_id already exists it is replaced.
Sourcepub fn poll(&mut self, task_id: u64) -> Option<Vec<u8>>
pub fn poll(&mut self, task_id: u64) -> Option<Vec<u8>>
Poll for the result of a previously submitted task.
Returns Some(result) if the task has completed, consuming the
result from the queue (subsequent polls for the same task_id
return None). Returns None if the task is still pending/running
or has already been consumed.
Sourcepub fn state(&self, task_id: u64) -> Option<&TaskState>
pub fn state(&self, task_id: u64) -> Option<&TaskState>
Query the current state of a task without consuming the result.
Returns None if no task with that task_id exists (either never
submitted or already consumed by Self::poll).
Sourcepub fn cancel(&mut self, task_id: u64) -> bool
pub fn cancel(&mut self, task_id: u64) -> bool
Cancel a pending or running task.
Returns true if the task was found and removed.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Number of tasks currently tracked (pending, running, or complete).
Trait Implementations§
Source§impl Debug for AsyncComputeQueue
impl Debug for AsyncComputeQueue
Source§impl Default for AsyncComputeQueue
impl Default for AsyncComputeQueue
Source§fn default() -> AsyncComputeQueue
fn default() -> AsyncComputeQueue
Auto Trait Implementations§
impl Freeze for AsyncComputeQueue
impl RefUnwindSafe for AsyncComputeQueue
impl Send for AsyncComputeQueue
impl Sync for AsyncComputeQueue
impl Unpin for AsyncComputeQueue
impl UnsafeUnpin for AsyncComputeQueue
impl UnwindSafe for AsyncComputeQueue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more