pub struct AsyncQueue<T> {
queue: Mutex<VecDeque<T>>,
capacity: usize,
not_empty: CondVar,
not_full: CondVar,
}Expand description
Bounded async queue. Producers push (blocks while full),
consumers recv (blocks while empty).
The mutex covers only the VecDeque push/pop, so slow work the
consumer does after recv is never inside a lock.
§Example
use karyon_core::async_util::AsyncQueue;
async {
let q = AsyncQueue::<u32>::new(8);
q.push(1).await;
let _ = q.recv().await;
};Fields§
§queue: Mutex<VecDeque<T>>§capacity: usize§not_empty: CondVar§not_full: CondVarImplementations§
Auto Trait Implementations§
impl<T> !Freeze for AsyncQueue<T>
impl<T> !RefUnwindSafe for AsyncQueue<T>
impl<T> Send for AsyncQueue<T>where
T: Send,
impl<T> Sync for AsyncQueue<T>where
T: Send,
impl<T> Unpin for AsyncQueue<T>where
T: Unpin,
impl<T> UnsafeUnpin for AsyncQueue<T>
impl<T> UnwindSafe for AsyncQueue<T>where
T: UnwindSafe,
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