Struct futures_mutex::FutMutex
[−]
[src]
pub struct FutMutex<T> { /* fields omitted */ }
A Mutex designed for use inside Futures. Works like BiLock<T>
from the futures
crate, but
with more than 2 handles.
THIS IS NOT A GENRAL PURPOSE MUTEX! IF YOU CALL poll_lock
OR lock
OUTSIDE THE CONTEXT OF A TASK, IT WILL PANIC AND EAT YOUR LAUNDRY.
This type provides a Mutex that will track tasks that are requesting the Mutex, and will unpark them in the order they request the lock.
As of now, there is no strong guarantee that a particular handle of the lock won't be starved. Hopefully the use of the queue will prevent this, but I haven't tried to test that.
Methods
impl<T> FutMutex<T>
[src]
fn new(t: T) -> FutMutex<T>
Create a new FutMutex wrapping around a value t
fn poll_lock(&self) -> Async<FutMutexGuard<T>>
This will attempt a non-blocking lock on the mutex, returning Async::NotReady
if it
can't be acquired.
This function will return immediatly with a FutMutexGuard
if the lock was acquired
successfully. When it drops, the lock will be unlocked.
If it can't acquire the lock, it will schedule the current task to be unparked when it might be able lock the mutex again.
Panics
This function will panic if called outside the context of a future's task.
fn lock(self) -> FutMutexAcquire<T>
Convert this lock into a future that resolves to a guard that allows access to the data.
This function returns FutMutexAcquire<T>
, which resolves to a FutMutexAcquired<T>
guard type.
The returned future will never return an error.
Trait Implementations
impl<T: Debug> Debug for FutMutex<T>
[src]
impl<T> Clone for FutMutex<T>
[src]
fn clone(&self) -> FutMutex<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