pub struct PersistentEngine { /* private fields */ }Expand description
Persistent-engine handle. Owns the host-side view of the ring
buffer. The GPU kernel is a separate concern gated behind
the persistent cargo feature.
Implementations§
Source§impl PersistentEngine
impl PersistentEngine
Sourcepub fn new(ring_size: u32) -> Self
pub fn new(ring_size: u32) -> Self
Construct an engine with a ring capacity of ring_size
slots. Must be a nonzero power of two so
index = slot & (cap-1) is correct.
Sourcepub fn try_new(ring_size: u32) -> Result<Self, String>
pub fn try_new(ring_size: u32) -> Result<Self, String>
Construct an engine only when the ring capacity already satisfies the persistent-ring indexing contract.
Sourcepub fn enqueue(&self, item: PersistentWorkItem) -> Result<u32, QueueFull>
pub fn enqueue(&self, item: PersistentWorkItem) -> Result<u32, QueueFull>
Enqueue a PersistentWorkItem. Returns Ok(slot_index) on success, or
Err(QueueFull) if the ring is full. Thread-safe under
concurrent producers (lock-free CAS on head).
Sourcepub fn claim(&self) -> Option<PersistentWorkItem>
pub fn claim(&self) -> Option<PersistentWorkItem>
Consumer-side claim. Returns the next available item or
None if the queue is empty. Thread-safe under concurrent
consumers.
Sourcepub fn is_done(&self, slot_idx: u32) -> Result<bool, String>
pub fn is_done(&self, slot_idx: u32) -> Result<bool, String>
Whether the consumer finished the item at slot_idx.
Sourcepub fn try_in_flight(&self) -> Result<u32, String>
pub fn try_in_flight(&self) -> Result<u32, String>
Number of items queued and pending claim.
Sourcepub fn head_counter(&self) -> u64
pub fn head_counter(&self) -> u64
Monotonic head counter (modulo ring_size = slot index).
Sourcepub fn tail_counter(&self) -> u64
pub fn tail_counter(&self) -> u64
Monotonic tail counter.