pub struct QueueReadiness<T>(/* private fields */);Expand description
A readiness signal backed by a ConcurrentQueue<T>.
The task considers itself ready when the queue is non-empty — i.e., one or more messages are waiting to be consumed.
This is the preferred signal for any TaskIterator that waits on a
producer→consumer queue (file events, build results, SSE reload signals).
The executor parks the task entirely and only wakes it when a message
arrives. Zero CPU spinning.
§Example
ⓘ
let queue = Arc::new(ConcurrentQueue::unbounded());
let readiness = QueueReadiness::new(queue.clone());
// In TaskIterator::next_status():
if let Ok(msg) = queue.pop() {
return Some(TaskStatus::Ready(msg));
}
Some(TaskStatus::Depends(Arc::new(readiness)))Implementations§
Source§impl<T> QueueReadiness<T>
impl<T> QueueReadiness<T>
Sourcepub fn new(queue: Arc<ConcurrentQueue<T>>) -> Self
pub fn new(queue: Arc<ConcurrentQueue<T>>) -> Self
Create a QueueReadiness that watches the given queue for messages.
Sourcepub fn queue(&self) -> Arc<ConcurrentQueue<T>> ⓘ
pub fn queue(&self) -> Arc<ConcurrentQueue<T>> ⓘ
Get a clone of the underlying queue for external mutation (pushing messages).
Trait Implementations§
Source§impl<T> Clone for QueueReadiness<T>
impl<T> Clone for QueueReadiness<T>
Auto Trait Implementations§
impl<T> Freeze for QueueReadiness<T>
impl<T> RefUnwindSafe for QueueReadiness<T>
impl<T> Send for QueueReadiness<T>
impl<T> Sync for QueueReadiness<T>
impl<T> Unpin for QueueReadiness<T>
impl<T> UnsafeUnpin for QueueReadiness<T>
impl<T> UnwindSafe for QueueReadiness<T>
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
Mutably borrows from an owned value. Read more