[−][src]Struct futures_util::lock::BiLock
A type of futures-powered synchronization primitive which is a mutex between two possible owners.
This primitive is not as generic as a full-blown mutex but is sufficient for
many use cases where there are only two possible owners of a resource. The
implementation of BiLock
can be more optimized for just the two possible
owners.
Note that it's possible to use this lock through a poll-style interface with
the poll_lock
method but you can also use it as a future with the lock
method that consumes a BiLock
and returns a future that will resolve when
it's locked.
A BiLock
is typically used for "split" operations where data which serves
two purposes wants to be split into two to be worked with separately. For
example a TCP stream could be both a reader and a writer or a framing layer
could be both a stream and a sink for messages. A BiLock
enables splitting
these two and then using each independently in a futures-powered fashion.
Methods
impl<T> BiLock<T>
[src][−]
pub fn new(t: T) -> (BiLock<T>, BiLock<T>)
[src][+]
pub fn poll_lock(&self, cx: &mut Context) -> Poll<BiLockGuard<T>>
[src][+]
ⓘImportant traits for BiLockAcquire<'a, T>pub fn lock(&self) -> BiLockAcquire<T>
[src][+]
pub fn reunite(self, other: Self) -> Result<T, ReuniteError<T>> where
T: Unpin,
[src][+]
T: Unpin,
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src][+]
impl<T, U> Into for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T> Borrow for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,