pub struct MVar<T> { /* private fields */ }Expand description
An MVar is a primitive that combines synchronization and the exchange
of a value. Its semantics are analogous to a synchronous channel of
size 1: if the MVar is full, then put blocks until it is emptied;
if the MVar is empty, then take blocks until it is filled.
MVars, first introduced in “Concurrent Haskell” are surprisingly versatile in use. They can be used as:
- a communication channel (with
putandtakecorresponding tosendandrecv); - a semaphore (with
putandtakecorresponding tosignalandwait); - a mutex (with
putandtakecorresponding tolockandunlock);
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for MVar<T>
impl<T> !RefUnwindSafe for MVar<T>
impl<T> Send for MVar<T>where
T: Send,
impl<T> Sync for MVar<T>where
T: Send,
impl<T> Unpin for MVar<T>
impl<T> !UnwindSafe for MVar<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<A, M> Handler<IndexedErasedUnbound<M>> for A
impl<A, M> Handler<IndexedErasedUnbound<M>> for A
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more