Struct gstd::sync::MutexLockFuture
source · pub struct MutexLockFuture<'a, T> { /* private fields */ }
Expand description
The future returned by the lock
method.
The output of the future is the MutexGuard
that can be obtained by using
await
syntax.
§Examples
In the following example, variable types are annotated explicitly for demonstration purposes only. Usually, annotating them is unnecessary because they can be inferred automatically.
use gstd::sync::{Mutex, MutexGuard, MutexLockFuture};
#[gstd::async_main]
async fn main() {
let mutex: Mutex<i32> = Mutex::new(42);
let future: MutexLockFuture<i32> = mutex.lock();
let guard: MutexGuard<i32> = future.await;
let value: i32 = *guard;
assert_eq!(value, 42);
}
Implementations§
source§impl<'a, T> MutexLockFuture<'a, T>
impl<'a, T> MutexLockFuture<'a, T>
sourcepub fn own_up_for(self, block_count: BlockCount) -> Result<Self>
pub fn own_up_for(self, block_count: BlockCount) -> Result<Self>
Sets the maximum number of blocks the mutex lock can be owned by some message before the ownership can be seized by another rival
Trait Implementations§
source§impl<'a, T> Future for MutexLockFuture<'a, T>
impl<'a, T> Future for MutexLockFuture<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for MutexLockFuture<'a, T>
impl<'a, T> !RefUnwindSafe for MutexLockFuture<'a, T>
impl<'a, T> Send for MutexLockFuture<'a, T>
impl<'a, T> Sync for MutexLockFuture<'a, T>
impl<'a, T> Unpin for MutexLockFuture<'a, T>
impl<'a, T> !UnwindSafe for MutexLockFuture<'a, T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn map<U, F>(self, f: F) -> Map<Self, F> ⓘ
fn map<U, F>(self, f: F) -> Map<Self, F> ⓘ
Map this future’s output to a different type, returning a new future of
the resulting type. Read more
§fn map_into<U>(self) -> MapInto<Self, U> ⓘ
fn map_into<U>(self) -> MapInto<Self, U> ⓘ
Map this future’s output to a different type, returning a new future of
the resulting type. Read more
§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F> ⓘ
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F> ⓘ
Chain on a computation for when a future finished, passing the result of
the future to the provided closure
f
. Read more§fn left_future<B>(self) -> Either<Self, B> ⓘ
fn left_future<B>(self) -> Either<Self, B> ⓘ
§fn right_future<A>(self) -> Either<A, Self> ⓘ
fn right_future<A>(self) -> Either<A, Self> ⓘ
§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
Convert this future into a single element stream. Read more
§fn flatten(self) -> Flatten<Self> ⓘ
fn flatten(self) -> Flatten<Self> ⓘ
Flatten the execution of this future when the output of this
future is itself another future. Read more
§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
Flatten the execution of this future when the successful result of this
future is a stream. Read more
§fn fuse(self) -> Fuse<Self> ⓘwhere
Self: Sized,
fn fuse(self) -> Fuse<Self> ⓘwhere
Self: Sized,
Fuse a future such that
poll
will never again be called once it has
completed. This method can be used to turn any Future
into a
FusedFuture
. Read more§fn inspect<F>(self, f: F) -> Inspect<Self, F> ⓘ
fn inspect<F>(self, f: F) -> Inspect<Self, F> ⓘ
Do something with the output of a future before passing it on. Read more
§fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
Wrap the future in a Box, pinning it. Read more
§fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
Wrap the future in a Box, pinning it. Read more
§fn unit_error(self) -> UnitError<Self> ⓘwhere
Self: Sized,
fn unit_error(self) -> UnitError<Self> ⓘwhere
Self: Sized,
Turns a
Future<Output = T>
into a
TryFuture<Ok = T, Error = ()
>.§fn never_error(self) -> NeverError<Self> ⓘwhere
Self: Sized,
fn never_error(self) -> NeverError<Self> ⓘwhere
Self: Sized,
Turns a
Future<Output = T>
into a
TryFuture<Ok = T, Error = Never
>.source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
§type IntoFuture = F
type IntoFuture = F
Which kind of future are we turning this into?
source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Creates a future from a value. Read more