Skip to content

Commit

Permalink
Add lock_api mapped read/write guard for RwLock
Browse files Browse the repository at this point in the history
  • Loading branch information
cavivie committed Jul 30, 2024
1 parent e57cfd0 commit 981c2a2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,18 @@ pub mod lock_api {
#[cfg_attr(docsrs, doc(cfg(feature = "rwlock")))]
pub type RwLockUpgradableReadGuard<'a, T> =
lock_api_crate::RwLockUpgradableReadGuard<'a, crate::RwLock<()>, T>;

/// A guard returned by [RwLockReadGuard::map] that provides immutable data access (compatible with [`lock_api`](https://crates.io/crates/lock_api)).
#[cfg(feature = "rwlock")]
#[cfg_attr(docsrs, doc(cfg(feature = "rwlock")))]
pub type MappedRwLockReadGuard<'a, T> =
lock_api_crate::MappedRwLockReadGuard<'a, crate::RwLock<()>, T>;

/// A guard returned by [RwLockWriteGuard::map] that provides mutable data access (compatible with [`lock_api`](https://crates.io/crates/lock_api)).
#[cfg(feature = "rwlock")]
#[cfg_attr(docsrs, doc(cfg(feature = "rwlock")))]
pub type MappedRwLockWriteGuard<'a, T> =
lock_api_crate::MappedRwLockWriteGuard<'a, crate::RwLock<()>, T>;
}

/// In the event of an invalid operation, it's best to abort the current process.
Expand Down

0 comments on commit 981c2a2

Please sign in to comment.