Skip to main content

VibeQueue

Struct VibeQueue 

Source
pub struct VibeQueue<T> { /* private fields */ }
Expand description

A bounded, thread-safe queue for holding tasks.

VibeQueue is used within each VibeNode to buffer incoming tasks. It sends NodeOverloaded and NodeIdle signals to the system when its size crosses defined percentage thresholds (watermarks).

Implementations§

Source§

impl<T> VibeQueue<T>

Source

pub fn len(&self) -> usize

Returns the current number of items in the queue.

Source

pub fn capacity(&self) -> usize

Returns the maximum capacity of the queue.

Source

pub fn is_empty(&self) -> bool

Returns true if the queue contains no items.

Source

pub fn is_full(&self) -> bool

Returns true if the queue has reached its maximum capacity.

Source

pub fn id(&self) -> QueueId

Returns the unique ID of this queue.

Source

pub fn close(&self)

Closes the queue, preventing any new items from being added.

Items already in the queue can still be removed.

Source

pub fn is_closed(&self) -> bool

Returns true if the queue has been closed.

Source§

impl VibeQueue<Task>

Source

pub fn with_watermarks_and_signal( node_id: NodeId, capacity: usize, low_watermark_percentage: f32, high_watermark_percentage: f32, signal_tx: Sender<SystemSignal>, ) -> Self

Creates a new VibeQueue with custom watermarks for signaling.

§Panics

Panics if capacity is 0 or if watermark percentages are invalid.

Source

pub fn new_with_signal( node_id: NodeId, capacity: usize, signal_tx: Sender<SystemSignal>, ) -> Self

Creates a new VibeQueue with default watermarks (25% and 75%).

Source

pub fn enqueue(&self, task: Task) -> Result<(), QueueError>

Adds a task to the back of the queue.

If adding the task causes the queue to become full, it sends a NodeOverloaded signal.

Source

pub fn dequeue(&self) -> Option<Task>

Removes a task from the front of the queue.

If removing the task causes a previously overloaded queue to drop below its low watermark, it sends a NodeIdle signal.

Trait Implementations§

Source§

impl<T> Clone for VibeQueue<T>

Source§

fn clone(&self) -> Self

Clones the queue.

This is a cheap operation, as it only clones the Arc pointers to the underlying queue data, not the data itself.

1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for VibeQueue<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for VibeQueue<T>
where Arc<Mutex<VecDeque<T>>>: Freeze,

§

impl<T> RefUnwindSafe for VibeQueue<T>

§

impl<T> Send for VibeQueue<T>
where Arc<Mutex<VecDeque<T>>>: Send,

§

impl<T> Sync for VibeQueue<T>
where Arc<Mutex<VecDeque<T>>>: Sync,

§

impl<T> Unpin for VibeQueue<T>
where Arc<Mutex<VecDeque<T>>>: Unpin,

§

impl<T> UnsafeUnpin for VibeQueue<T>

§

impl<T> UnwindSafe for VibeQueue<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.