Struct qutex::QrwLock
[−]
[src]
pub struct QrwLock<T> { /* fields omitted */ }
A queue-backed read/write data lock.
As with any queue-backed system, deadlocks must be carefully avoided when interoperating with other queues.
Methods
impl<T> QrwLock<T>
[src]
fn new(val: T) -> QrwLock<T>
Creates and returns a new QrwLock
.
fn request_read(self) -> FutureReadGuard<T>
: please use ::read
instead
Returns a new FutureReadGuard
which can be used as a future and will
resolve into a ReadGuard
.
fn request_write(self) -> FutureWriteGuard<T>
: please use ::write
instead
Returns a new FutureWriteGuard
which can be used as a future and will
resolve into a WriteGuard
.
fn read(self) -> FutureReadGuard<T>
Returns a new FutureReadGuard
which can be used as a future and will
resolve into a ReadGuard
.
fn write(self) -> FutureWriteGuard<T>
Returns a new FutureWriteGuard
which can be used as a future and will
resolve into a WriteGuard
.
unsafe fn push_request(&self, req: QrwRequest)
Pushes a lock request onto the queue.
fn get_mut(&mut self) -> Option<&mut T>
Returns a mutable reference to the inner Vec
if there are currently
no other copies of this QrwLock
.
Since this call borrows the inner lock mutably, no actual locking needs to take place---the mutable borrow statically guarantees no locks exist.
fn as_ptr(&self) -> *const T
Returns a reference to the inner value.
This is fraught with potential peril.
fn as_mut_ptr(&self) -> *mut T
Returns a mutable reference to the inner value.
Drinking water from the tap in 1850's London would be safer.
unsafe fn process_queue(&self)
Pops the next lock request in the queue if possible.
If this lock is released, read or write-locks this lock and unparks the next requester task in the queue.
If this lock is write-locked, this function does nothing.
If this lock is read-locked and the next request or consecutive requests in the queue are read requests, those requests will be fulfilled, unparking their respective tasks and incrementing the read-lock count appropriately.
unsafe fn upgrade_read_lock(&self) -> Result<(), Receiver<()>>
Converts a single read lock (read count of '1') into a write lock.
Returns an error containing a oneshot receiver if there is currently more than one read lock. When the read count reaches one, the receiver channel will be completed (i.e. poll it).
Panics if there are no read locks.
Do not call this method directly unless you are using a custom guard
or are otherwise managing the lock state manually. Use
ReadGuard::upgrade
instead.
unsafe fn downgrade_write_lock(&self)
Converts a write lock into a read lock then processes the queue, allowing additional read requests to acquire locks.
Use WriteGuard::downgrade
rather than calling this directly.
unsafe fn release_read_lock(&self)
Decreases the reader count by one and unparks the next requester task in the queue if possible.
If a reader is waiting to be upgraded and the read lock count reaches 1, the upgrade sender will be completed.
unsafe fn release_write_lock(&self)
Unlocks this lock and unparks the next requester task in the queue if possible.
Trait Implementations
impl<T: Debug> Debug for QrwLock<T>
[src]
impl<T> From<T> for QrwLock<T>
[src]
impl<T> Clone for QrwLock<T>
[src]
fn clone(&self) -> QrwLock<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more