#[repr(C)]
pub struct LocalQueue<'l, T> { /* private fields */ }

Implementations§

source§

impl<'l, T> LocalQueue<'l, T>

source

pub fn is_empty(&self) -> bool

source

pub fn is_full(&self) -> bool

source

pub fn len(&self) -> usize

source

pub fn push_back(&self, item: T)

If the queue is full, first push half to global, then push the item to global.

Examples
use work_steal_queue::WorkStealQueue;

let queue = WorkStealQueue::new(1, 2);
let local = queue.local_queue();
for i in 0..4 {
    local.push_back(i);
}
assert_eq!(local.pop_front(), Some(3));
assert_eq!(local.pop_front(), Some(0));
assert_eq!(local.pop_front(), Some(1));
assert_eq!(local.pop_front(), Some(2));
assert_eq!(local.pop_front(), None);
source

pub fn pop_front(&self) -> Option<T>

If the queue is empty, first try steal from global, then try steal from siblings.

Examples
use work_steal_queue::WorkStealQueue;

let queue = WorkStealQueue::new(1, 32);
queue.push(1);
queue.push(2);
let local = queue.local_queue();
assert_eq!(local.pop_front(), Some(1));
assert_eq!(local.pop_front(), Some(2));
assert_eq!(local.pop_front(), None);
Examples
use work_steal_queue::WorkStealQueue;
let queue = WorkStealQueue::new(2, 64);
let local0 = queue.local_queue();
local0.push_back(2);
local0.push_back(3);
let local1 = queue.local_queue();
local1.push_back(0);
local1.push_back(1);
for i in 0..4 {
    assert_eq!(local1.pop_front(), Some(i));
}
assert_eq!(local0.pop_front(), None);
assert_eq!(local1.pop_front(), None);
assert_eq!(queue.pop(), None);

Trait Implementations§

source§

impl<'l, T: Debug> Debug for LocalQueue<'l, T>

source§

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

Formats the value using the given formatter. Read more
source§

impl<T> Drop for LocalQueue<'_, T>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T: Send> Send for LocalQueue<'_, T>

source§

impl<T: Send> Sync for LocalQueue<'_, T>

Auto Trait Implementations§

§

impl<'l, T> !RefUnwindSafe for LocalQueue<'l, T>

§

impl<'l, T> Unpin for LocalQueue<'l, T>

§

impl<'l, T> !UnwindSafe for LocalQueue<'l, T>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> Pointable for T

source§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.