pub struct LimitAccessQueue<T, State> {
pub val: Vec<T>,
/* private fields */
}Fields§
§val: Vec<T>Implementations§
Source§impl<T, State> LimitAccessQueue<T, State>
impl<T, State> LimitAccessQueue<T, State>
pub fn new() -> (PrimaryAccessor<T, State>, SecondaryAccessor<T, State>)
pub fn set_state(&mut self, state: State)
pub fn get_state(&mut self) -> State
pub fn pop(&mut self) -> Option<T>
pub fn pop_count(&mut self, count: usize) -> Option<Vec<T>>
Sourcepub fn steal(&mut self) -> Option<Vec<T>>
pub fn steal(&mut self) -> Option<Vec<T>>
Steals all the un-popped values from the queue. It can then be reused elsewhere.
use parallel_task::{
accessors::limit_queue::LimitAccessQueue,
push_workers::worker_thread::Coordination};
let values = (0..100_000).collect::<Vec<_>>();
let (mut primary, _) = LimitAccessQueue::<i32,Coordination>::new();
_ = primary.write(values);
let vec = primary.steal().unwrap(); //This step should not fail here. But unwrap not advised in production
assert_eq!(vec.len(), 100_000);Sourcepub fn steal_half(&mut self) -> Option<Vec<T>>
pub fn steal_half(&mut self) -> Option<Vec<T>>
Steals half the un-popped values from the queue. It can then be reused elsewhere.
use parallel_task::{
accessors::limit_queue::LimitAccessQueue,
push_workers::worker_thread::Coordination};
let values = (0..100_000).collect::<Vec<_>>();
let (mut primary, _) = LimitAccessQueue::<i32,Coordination>::new();
_ = primary.write(values);
let vec = primary.steal_half().unwrap(); //This step should not fail here. But unwrap not advised in production
assert_eq!(vec.len(), 50_000);pub fn is_empty(&mut self) -> bool
pub fn len(&mut self) -> usize
pub fn atomic_write_block_to_true(&mut self) -> Result<bool, bool>
pub fn with_write_block<F, Output>(&mut self, f: F) -> Outputwhere
F: FnOnce(&mut Self) -> Output,
pub fn push(&mut self, value: T)
pub fn write(&mut self, values: Vec<T>)
pub fn replace(&mut self, values: Vec<T>)
pub fn is_write_blocked(&self) -> bool
Auto Trait Implementations§
impl<T, State> !Freeze for LimitAccessQueue<T, State>
impl<T, State> RefUnwindSafe for LimitAccessQueue<T, State>where
State: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, State> Send for LimitAccessQueue<T, State>
impl<T, State> Sync for LimitAccessQueue<T, State>
impl<T, State> Unpin for LimitAccessQueue<T, State>
impl<T, State> UnsafeUnpin for LimitAccessQueue<T, State>where
State: UnsafeUnpin,
impl<T, State> UnwindSafe for LimitAccessQueue<T, State>where
State: UnwindSafe,
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
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.