pub enum Queue<T> {
Bounded {
sender: Arc<Mutex<Option<Sender<T>>>>,
receiver: Arc<Mutex<Option<Receiver<T>>>>,
capacity: usize,
},
Unbounded {
sender: Arc<Mutex<Option<UnboundedSender<T>>>>,
receiver: Arc<Mutex<Option<UnboundedReceiver<T>>>>,
},
}
Expand description
A Queue represents a concurrent queue with a Stream interface for dequeuing and async methods for enqueuing.
Variants§
Bounded
Fields
Unbounded
Fields
§
sender: Arc<Mutex<Option<UnboundedSender<T>>>>
§
receiver: Arc<Mutex<Option<UnboundedReceiver<T>>>>
Implementations§
Source§impl<T> Queue<T>where
T: Send + 'static,
impl<T> Queue<T>where
T: Send + 'static,
Sourcepub async fn enqueue(&self, item: T) -> Result<(), QueueError>
pub async fn enqueue(&self, item: T) -> Result<(), QueueError>
Enqueue an item into the queue
Sourcepub async fn try_enqueue(&self, item: T) -> Result<(), QueueError>
pub async fn try_enqueue(&self, item: T) -> Result<(), QueueError>
Try to enqueue an item without blocking
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Queue<T>
impl<T> !RefUnwindSafe for Queue<T>
impl<T> Send for Queue<T>where
T: Send,
impl<T> Sync for Queue<T>where
T: Send,
impl<T> Unpin for Queue<T>
impl<T> !UnwindSafe for Queue<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