[−][src]Struct fast_async_mutex::mutex_unordered::UnorderedMutex
An async unordered
mutex.
It will be works with any async runtime in Rust
, it may be a tokio
, smol
, async-std
and etc..
The main difference with the standard Mutex
is unordered mutex will not check an ordering of blocking.
This way is much faster, but there are some risks what someone mutex lock will be executed much later.
Implementations
impl<T> UnorderedMutex<T>
[src]
pub const fn new(data: T) -> UnorderedMutex<T>
[src]
Create a new UnorderedMutex
pub const fn lock(&self) -> UnorderedMutexGuardFuture<'_, T>ⓘNotable traits for UnorderedMutexGuardFuture<'a, T>
impl<'a, T: ?Sized> Future for UnorderedMutexGuardFuture<'a, T> type Output = UnorderedMutexGuard<'a, T>;
[src]
Notable traits for UnorderedMutexGuardFuture<'a, T>
impl<'a, T: ?Sized> Future for UnorderedMutexGuardFuture<'a, T> type Output = UnorderedMutexGuard<'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_unordered::UnorderedMutex; #[tokio::main] async fn main() { let mutex = UnorderedMutex::new(10); let guard = mutex.lock().await; assert_eq!(*guard, 10); }
pub fn lock_owned(self: &Arc<Self>) -> UnorderedMutexOwnedGuardFuture<T>ⓘNotable traits for UnorderedMutexOwnedGuardFuture<T>
impl<T: ?Sized> Future for UnorderedMutexOwnedGuardFuture<T> type Output = UnorderedMutexOwnedGuard<T>;
[src]
Notable traits for UnorderedMutexOwnedGuardFuture<T>
impl<T: ?Sized> Future for UnorderedMutexOwnedGuardFuture<T> type Output = UnorderedMutexOwnedGuard<T>;
Acquires the mutex.
Returns a guard that releases the mutex and wake the next locker when dropped.
UnorderedMutexOwnedGuardFuture
have a 'static
lifetime, but requires the Arc<Mutex<T>>
type
Examples
use fast_async_mutex::mutex_unordered::UnorderedMutex; use std::sync::Arc; #[tokio::main] async fn main() { let mutex = Arc::new(UnorderedMutex::new(10)); let guard = mutex.lock_owned().await; assert_eq!(*guard, 10); }
Trait Implementations
impl<T: Debug> Debug for UnorderedMutex<T>
[src]
impl<T: ?Sized + Send> Send for UnorderedMutex<T>
[src]
impl<T: ?Sized + Send> Sync for UnorderedMutex<T>
[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for UnorderedMutex<T>
impl<T: ?Sized> Unpin for UnorderedMutex<T> where
T: Unpin,
T: Unpin,
impl<T: ?Sized> UnwindSafe for UnorderedMutex<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>,