[−][src]Struct fast_async_mutex::mutex::Mutex
The simple Mutex, which will provide unique access to you data between multiple threads/futures.
Implementations
impl<T> Mutex<T>
[src]
impl<T: ?Sized> Mutex<T>
[src]
pub const 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.
MutexOwnedGuardFuture
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 + ?Sized> Debug for Mutex<T>
[src]
impl<T: ?Sized> Send for Mutex<T> where
T: Send,
[src]
T: Send,
impl<T: ?Sized> Sync for Mutex<T> where
T: Send + Sync,
[src]
T: Send + Sync,
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,
pub 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.
pub 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>,