pub trait Resize: MPMCQueue {
// Required method
fn resize(&self, size: usize) -> bool;
}Expand description
An extension trait for MPMCQueue that allows dynamic resizing of the queue.
This trait makes no guarantees regarding the synchronization model or
blocking behavior of the resize method itself. It only guarantees that
the core MPMCQueue operations maintain their original guarantees.
§Examples
#[cfg(feature = "dynamic")]
fn run() {
use nblf_queue::{DynamicQueue, MPMCQueue, Resize};
let q = DynamicQueue::new(1);
assert!(q.push(1).is_ok());
assert!(q.is_full());
assert!(q.resize(2 + q.capacity()));
assert_eq!(q.capacity(), 3);
assert!(!q.is_full());
assert!(q.push(2).is_ok());
assert!(q.push(3).is_ok());
assert_eq!(q.pop(), Some(1));
assert_eq!(q.pop(), Some(2));
assert_eq!(q.pop(), Some(3));
assert!(q.is_empty());
}
#[cfg(feature = "dynamic")]
run();Required Methods§
Sourcefn resize(&self, size: usize) -> bool
fn resize(&self, size: usize) -> bool
Attempts to resize the capacity of the queue to size slots.
Note: This method may block or fail spuriously.
Further a growth event may not be considered finished until some time after the call to resize.
Returns true if the resize was successfull, or false if
it failed. Failure can occur due to allocator exhaustion, thread
contention, or other implementation-specific conditions.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".