Skip to main content

LimitAccessQueue

Struct LimitAccessQueue 

Source
pub struct LimitAccessQueue<T, State> {
    pub val: Vec<T>,
    /* private fields */
}

Fields§

§val: Vec<T>

Implementations§

Source§

impl<T, State> LimitAccessQueue<T, State>
where State: Default + Clone,

Source

pub fn new() -> (PrimaryAccessor<T, State>, SecondaryAccessor<T, State>)

Source

pub fn set_state(&mut self, state: State)

Source

pub fn get_state(&mut self) -> State

Source

pub fn pop(&mut self) -> Option<T>

Source

pub fn pop_count(&mut self, count: usize) -> Option<Vec<T>>

Source

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);
Source

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);
Source

pub fn is_empty(&mut self) -> bool

Source

pub fn len(&mut self) -> usize

Source

pub fn atomic_write_block_to_true(&mut self) -> Result<bool, bool>

Source

pub fn with_write_block<F, Output>(&mut self, f: F) -> Output
where F: FnOnce(&mut Self) -> Output,

Source

pub fn push(&mut self, value: T)

Source

pub fn write(&mut self, values: Vec<T>)

Source

pub fn replace(&mut self, values: Vec<T>)

Source

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>
where State: Send, T: Send,

§

impl<T, State> Sync for LimitAccessQueue<T, State>
where State: Sync, T: Sync,

§

impl<T, State> Unpin for LimitAccessQueue<T, State>
where State: Unpin, T: Unpin,

§

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> 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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V