[−][src]Struct fast_async_mutex::mutex::Mutex
An async mutex.
It will be works with any async runtime in Rust
, it may be a tokio
, smol
, async-std
and etc..
Implementations
impl<T> Mutex<T>
[src]
pub const fn new(data: T) -> Mutex<T>
[src]
pub fn lock(&self) -> MutexGuardFuture<'_, T>ⓘNotable traits for MutexGuardFuture<'a, T>
impl<'a, T: ?Sized> Future for MutexGuardFuture<'a, T> type Output = MutexGuard<'a, T>;
[src]
Notable traits for MutexGuardFuture<'a, T>
impl<'a, T: ?Sized> Future for MutexGuardFuture<'a, T> type Output = MutexGuard<'a, T>;
Acquires the mutex.
Returns a guard that releases the mutex and wake the next locker when dropped.
Examples
use fast_async_mutex::mutex::Mutex; #[tokio::main] async fn main() { let mutex = Mutex::new(10); let guard = mutex.lock().await; assert_eq!(*guard, 10); }
pub fn lock_owned(self: &Arc<Self>) -> MutexOwnedGuardFuture<T>ⓘNotable traits for MutexOwnedGuardFuture<T>
impl<T: ?Sized> Future for MutexOwnedGuardFuture<T> type Output = MutexOwnedGuard<T>;
[src]
Notable traits for MutexOwnedGuardFuture<T>
impl<T: ?Sized> Future for MutexOwnedGuardFuture<T> type Output = MutexOwnedGuard<T>;
Acquires the mutex.
Returns a guard that releases the mutex and wake the next locker when dropped.
MutexOwnedGuard
have a 'static
lifetime, but requires the Arc<Mutex<T>>
type
Examples
use fast_async_mutex::mutex::Mutex; use std::sync::Arc; #[tokio::main] async fn main() { let mutex = Arc::new(Mutex::new(10)); let guard = mutex.lock_owned().await; assert_eq!(*guard, 10); }
Trait Implementations
impl<T: Debug> Debug for Mutex<T>
[src]
impl<T: ?Sized + Send> Send for Mutex<T>
[src]
impl<T: ?Sized + Send> Sync for Mutex<T>
[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for Mutex<T>
impl<T: ?Sized> Unpin for Mutex<T> where
T: Unpin,
T: Unpin,
impl<T: ?Sized> UnwindSafe for Mutex<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,