pub struct AccessQueue<T> { /* private fields */ }Expand description
The AccessQueue which guards access to some item.
Implementations§
Source§impl<T> AccessQueue<T>
impl<T> AccessQueue<T>
Sourcepub fn new(inner: T, count: usize) -> AccessQueue<T>
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.
Sourcepub fn block(&self, amt: usize) -> bool
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.
Sourcepub fn release(&self, amt: usize)
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.
Sourcepub fn skip_queue(&self) -> &T
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.