pub struct Mutex<T: ?Sized>(/* private fields */);Expand description
Documentation still incomplete. API similar to std::sync::Mutex.
§Examples
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use std::task::{Context, Poll};
fn poll_shared_future<F: Future>(
fut: &Pin<Arc<pinnable::Mutex<F>>>,
ctx: &mut Context<'_>,
) -> Poll<F::Output> {
fut.as_ref().lock().unwrap().as_mut().poll(ctx)
}Implementations§
Source§impl<T> Mutex<T>
impl<T> Mutex<T>
pub fn new(t: T) -> Self
pub fn into_inner(self) -> LockResult<T>
Source§impl<T: ?Sized> Mutex<T>
impl<T: ?Sized> Mutex<T>
pub fn lock(self: Pin<&Self>) -> LockResult<PinMutexGuard<'_, T>>
pub fn lock_no_pin(&self) -> LockResult<NoPinMutexGuard<'_, T>>
pub fn try_lock(self: Pin<&Self>) -> TryLockResult<PinMutexGuard<'_, T>>
pub fn try_lock_no_pin(&self) -> TryLockResult<NoPinMutexGuard<'_, T>>
pub fn is_poisoned(&self) -> bool
pub fn get_mut(self: Pin<&mut Self>) -> LockResult<Pin<&mut T>>
pub fn get_mut_no_pin(&mut self) -> LockResult<&mut T>
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for Mutex<T>
impl<T> RefUnwindSafe for Mutex<T>where
T: ?Sized,
impl<T> Send for Mutex<T>
impl<T> Sync for Mutex<T>
impl<T> Unpin for Mutex<T>
impl<T> UnwindSafe for Mutex<T>where
T: ?Sized,
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