access_queue

Struct AccessQueue

Source
pub struct AccessQueue<T> { /* private fields */ }
Expand description

The AccessQueue which guards access to some item.

Implementations§

Source§

impl<T> AccessQueue<T>

Source

pub fn new(inner: T, count: usize) -> AccessQueue<T>

Construct a new AccessQueue, which guards the inner value and allows only count concurrent accesses to occur simultaneously.

Source

pub fn block(&self, amt: usize) -> bool

Block amt accesses.

This reduces the number of concurrent accesses to the guarded item that are allowed. Until release is called, this many accesses are blocked from occurring.

This function returns true if it successfully blocked these accesses, and false if it could not. Blocking only fails if there are not as many accesses left in the queue as the caller has attempted to block.

Source

pub fn release(&self, amt: usize)

Release amt additional accesses.

This increases the number of concurrent accesses to the guarded item that are alloewd. It can be paired with block to raise and lower the limit.

Source

pub fn access(&self) -> Access<'_, T>

Wait in the queue to access the guarded item.

Source

pub fn skip_queue(&self) -> &T

Skip the access queue and get a reference to the inner item.

This does not modify the number of simultaneous accesses allowed. It can be useful if the AccessQueue is only limited certain patterns of use on the inner item.

Source

pub fn get_mut(&mut self) -> &mut T

Get the inner item mutably.

This requires mutable access to the AccessQueue, guaranteeing that no simultaneous accesses are occurring.

Trait Implementations§

Source§

impl<T: Debug> Debug for AccessQueue<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for AccessQueue<T>

§

impl<T> RefUnwindSafe for AccessQueue<T>
where T: RefUnwindSafe,

§

impl<T> Send for AccessQueue<T>
where T: Send,

§

impl<T> Sync for AccessQueue<T>
where T: Sync,

§

impl<T> Unpin for AccessQueue<T>
where T: Unpin,

§

impl<T> UnwindSafe for AccessQueue<T>
where 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, 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.