pub struct FillQueue<T, A: Allocator = Global> { /* private fields */ }
Available on crate feature alloc only.

Implementations

Creates a new FillQueue with the global allocator.

Example
use utils_atomics::prelude::*;
 
let queue = FillQueue::<i32>::new();

Creates a new FillQueue with the given allocator.

Example
#![feature(allocator_api)]
 
use utils_atomics::prelude::*;
use std::alloc::Global;
 
let queue = FillQueue::<i32>::new_in(Global);

Returns a reference to this queue’s allocator.

Example
#![feature(allocator_api)]
 
use utils_atomics::prelude::*;
use std::alloc::Global;
 
let queue = FillQueue::<i32>::new();
let alloc : &Global = queue.allocator();

Returns true if the que is currently empty, false otherwise.

Safety

Whilst this method is not unsafe, it’s result should be considered immediately stale.

Example
use utils_atomics::prelude::*;
 
let queue = FillQueue::<i32>::new();
assert!(queue.is_empty());

Uses atomic operations to push an element to the queue.

Panics

This method panics if alloc fails to allocate the memory needed for the node.

Example
use utils_atomics::prelude::*;
 
let queue = FillQueue::<i32>::new();
queue.push(1);
assert_eq!(queue.chop().next(), Some(1));

Uses non-atomic operations to push an element to the queue.

Panics

This method panics if alloc fails to allocate the memory needed for the node.

Example
use utils_atomics::prelude::*;
 
let mut queue = FillQueue::<i32>::new();
queue.push_mut(1);
assert_eq!(queue.chop_mut().next(), Some(1));

Uses atomic operations to push an element to the queue.

Errors

This method returns an error if alloc fails to allocate the memory needed for the node.

Example
use utils_atomics::prelude::*;
 
let queue = FillQueue::<i32>::new();
assert!(queue.try_push(1).is_ok());
assert_eq!(queue.chop().next(), Some(1));

Uses non-atomic operations to push an element to the queue.

Safety

This method is safe because the mutable reference guarantees we are the only thread that can access this queue.

Errors

This method returns an error if alloc fails to allocate the memory needed for the node.

Example
use utils_atomics::prelude::*;
 
let mut queue = FillQueue::<i32>::new();
assert!(queue.try_push_mut(1).is_ok());
assert_eq!(queue.chop_mut().next(), Some(1));

Returns a LIFO (Last In First Out) iterator over a chopped chunk of a FillQueue. The elements that find themselves inside the chopped region of the queue will be accessed through non-atomic operations.

Example
use utils_atomics::prelude::*;
 
let queue = FillQueue::<i32>::new();
 
queue.push(1);
queue.push(2);
queue.push(3);
 
let mut iter = queue.chop();
assert_eq!(iter.next(), Some(3));
assert_eq!(iter.next(), Some(2));
assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next(), None)

Returns a LIFO (Last In First Out) iterator over a chopped chunk of a FillQueue. The chopping is done with non-atomic operations.

Safety

This method is safe because the mutable reference guarantees we are the only thread that can access this queue.

Example
use utils_atomics::prelude::*;
 
let mut queue = FillQueue::<i32>::new();
 
queue.push_mut(1);
queue.push_mut(2);
queue.push_mut(3);
 
let mut iter = queue.chop_mut();
assert_eq!(iter.next(), Some(3));
assert_eq!(iter.next(), Some(2));
assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next(), None)

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.