Struct concurrency_traits::rw_lock::CustomRwLock[][src]

pub struct CustomRwLock<T, R> { /* fields omitted */ }
Expand description

A custom rw lock that can be built from any RawTryRwLock variant

Implementations

impl<T, R> CustomRwLock<T, R>[src]

pub fn from_raw(raw_lock: R, data: T) -> Self[src]

Creates a lock from a RawTryRwLock variant

pub fn new(data: T) -> Self where
    R: Default
[src]

Creates a lock using thr RawTryRwLock variant’s default implementation

Trait Implementations

impl<'a, T, R> AsyncRwLock<'a> for CustomRwLock<T, R> where
    T: 'a + Send + Sync,
    R: RawAsyncRwLock + 'a + Send + Sync
[src]

fn read_async<'async_trait>(
    &'a self
) -> Pin<Box<dyn Future<Output = Self::ReadGuard> + Send + 'async_trait>> where
    'a: 'async_trait,
    Self: 'async_trait, 
[src]

Reads the lock asynchronously, giving a future that will contain the read lock Read more

fn write_async<'async_trait>(
    &'a self
) -> Pin<Box<dyn Future<Output = Self::WriteGuard> + Send + 'async_trait>> where
    'a: 'async_trait,
    Self: 'async_trait, 
[src]

Writes to the lock asynchronously, giving a future that will contain the write lock Read more

impl<'a, T, R> AsyncTimeoutRwLock<'a> for CustomRwLock<T, R> where
    T: 'a + Send + Sync,
    R: RawAsyncTimeoutRwLock + 'a + Send + Sync
[src]

fn read_timeout_async<'async_trait>(
    &'a self,
    timeout: Duration
) -> Pin<Box<dyn Future<Output = Option<Self::ReadGuard>> + Send + 'async_trait>> where
    'a: 'async_trait,
    Self: 'async_trait, 
[src]

Reads from the lock with a timeout asynchronously

fn write_timeout_async<'async_trait>(
    &'a self,
    timeout: Duration
) -> Pin<Box<dyn Future<Output = Option<Self::WriteGuard>> + Send + 'async_trait>> where
    'a: 'async_trait,
    Self: 'async_trait, 
[src]

Writes to the lock with a timeout asynchronously

impl<T: Debug, R: Debug> Debug for CustomRwLock<T, R>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<'a, T, R> RwLock<'a> for CustomRwLock<T, R> where
    T: 'a,
    R: RawRwLock + 'a, 
[src]

fn read(&'a self) -> Self::ReadGuard[src]

Reads from the lock, blocking until able.

fn write(&'a self) -> Self::WriteGuard[src]

Writes to the lock, blocking until able.

impl<'a, T, R> RwLockSized<'a> for CustomRwLock<T, R> where
    T: 'a,
    R: RawRwLock + 'a, 
[src]

fn read_func<O>(&'a self, func: impl FnOnce(&Self::Item) -> O) -> O[src]

Blocks until reading from the lock and then runs func on the result Read more

fn write_func<O>(&'a self, func: impl FnOnce(&mut Self::Item) -> O) -> O[src]

Blocks until writing to the lock and then runs func on the result Read more

impl<'a, T, R> TimeoutRwLock<'a> for CustomRwLock<T, R> where
    T: 'a,
    R: RawTimeoutRwLock + 'a, 
[src]

fn read_timeout(&'a self, timeout: Duration) -> Option<Self::ReadGuard>[src]

Reads from the lock with a timeout

fn write_timeout(&'a self, timeout: Duration) -> Option<Self::WriteGuard>[src]

Writes to the lock with a timeout

impl<'a, T, R> TimeoutRwLockSized<'a> for CustomRwLock<T, R> where
    T: 'a,
    R: RawTimeoutRwLock + 'a, 
[src]

fn read_timeout_func<O>(
    &'a self,
    timeout: Duration,
    func: impl FnOnce(Option<&Self::Item>) -> O
) -> O
[src]

Reads from the lock with a timeout running func on the result Read more

fn write_timeout_func<O>(
    &'a self,
    timeout: Duration,
    func: impl FnOnce(Option<&mut Self::Item>) -> O
) -> O
[src]

Writes to the lock with a timeout running func on the result Read more

impl<'a, T, R> TryRwLock<'a> for CustomRwLock<T, R> where
    T: 'a,
    R: RawTryRwLock + 'a, 
[src]

type Item = T

The item stored by this lock

type ReadGuard = CustomReadGuard<'a, T, R>

The guard for reading from this lock

type WriteGuard = CustomWriteGuard<'a, T, R>

The guard for writing to this lock

fn try_read(&'a self) -> Option<Self::ReadGuard>[src]

Tries to read from the lock, returning None if cannot immediately

fn try_write(&'a self) -> Option<Self::WriteGuard>[src]

Tries to write to the lock, returning None if not able to immediately

impl<'a, T, R> TryRwLockSized<'a> for CustomRwLock<T, R> where
    T: 'a,
    R: RawTryRwLock + 'a, 
[src]

fn try_read_func<O>(&'a self, func: impl FnOnce(Option<&Self::Item>) -> O) -> O[src]

Tries to read from the lock and runs func on the result Read more

fn try_write_func<O>(
    &'a self,
    func: impl FnOnce(Option<&mut Self::Item>) -> O
) -> O
[src]

Tries to write to the lock and runs func on the result Read more

impl<'a, T, R> AsyncTimeoutUpgradeRwLock<'a> for CustomRwLock<T, R> where
    T: 'a + Send + Sync,
    R: RawAsyncTimeoutUpgradeRwLock + 'a + Send + Sync
[src]

impl<'a, T, R> AsyncUpgradeRwLock<'a> for CustomRwLock<T, R> where
    T: 'a + Send + Sync,
    R: RawAsyncUpgradeRwLock + 'a + Send + Sync
[src]

impl<'a, T, R> DowngradeRwLock<'a> for CustomRwLock<T, R> where
    T: 'a,
    R: RawDowngradeRwLock + 'a, 
[src]

impl<T, R> Sync for CustomRwLock<T, R> where
    T: Sync,
    R: Sync
[src]

impl<'a, T, R> TryUpgradeRwLock<'a> for CustomRwLock<T, R> where
    T: 'a,
    R: RawTryUpgradeRwLock + 'a, 
[src]

impl<'a, T, R> UpgradeRwLock<'a> for CustomRwLock<T, R> where
    T: 'a,
    R: RawUpgradeRwLock + 'a, 
[src]

impl<'a, T, R> UpgradeTimeoutRwLock<'a> for CustomRwLock<T, R> where
    T: 'a,
    R: RawUpgradeTimeoutRwLock + 'a, 
[src]

Auto Trait Implementations

impl<T, R> !RefUnwindSafe for CustomRwLock<T, R>

impl<T, R> Send for CustomRwLock<T, R> where
    R: Send,
    T: Send

impl<T, R> Unpin for CustomRwLock<T, R> where
    R: Unpin,
    T: Unpin

impl<T, R> UnwindSafe for CustomRwLock<T, R> where
    R: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

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]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.