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]

Create a new FutMutex wrapping around a value 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.

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]

Formats the value using the given formatter.

impl<T> Clone for FutMutex<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more