summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-03-04 02:05:07 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-03-04 02:05:07 +0000
commit72d79e8b7a4010f73975eb577febdf6db5934799 (patch)
tree78a003706c177f2ed754dc2bc85e7905450ba91d
parent8e1c2abe6a25e7a68976ffd172d40444d07f5295 (diff)
parent4783e793f2b852827560a2d96d4c2324cf93137b (diff)
downloadlock_api-android13-s2-release.tar.gz
Snap for 8249732 from 4783e793f2b852827560a2d96d4c2324cf93137b to tm-releaseandroid-vts-13.0_r8android-vts-13.0_r7android-vts-13.0_r6android-vts-13.0_r5android-vts-13.0_r4android-vts-13.0_r3android-vts-13.0_r2android-vts-13.0_r1android-security-13.0.0_r9android-security-13.0.0_r8android-security-13.0.0_r7android-security-13.0.0_r6android-security-13.0.0_r5android-security-13.0.0_r4android-security-13.0.0_r3android-security-13.0.0_r2android-security-13.0.0_r17android-security-13.0.0_r16android-security-13.0.0_r15android-security-13.0.0_r14android-security-13.0.0_r13android-security-13.0.0_r12android-security-13.0.0_r11android-security-13.0.0_r10android-security-13.0.0_r1android-platform-13.0.0_r9android-platform-13.0.0_r8android-platform-13.0.0_r7android-platform-13.0.0_r6android-platform-13.0.0_r5android-platform-13.0.0_r4android-platform-13.0.0_r3android-platform-13.0.0_r2android-platform-13.0.0_r19android-platform-13.0.0_r18android-platform-13.0.0_r17android-platform-13.0.0_r16android-platform-13.0.0_r15android-platform-13.0.0_r14android-platform-13.0.0_r13android-platform-13.0.0_r12android-platform-13.0.0_r11android-platform-13.0.0_r10android-platform-13.0.0_r1android-cts-13.0_r8android-cts-13.0_r7android-cts-13.0_r6android-cts-13.0_r5android-cts-13.0_r4android-cts-13.0_r3android-cts-13.0_r2android-cts-13.0_r1android-13.0.0_r8android-13.0.0_r7android-13.0.0_r6android-13.0.0_r5android-13.0.0_r4android-13.0.0_r31android-13.0.0_r3android-13.0.0_r2android-13.0.0_r12android-13.0.0_r1android13-tests-releaseandroid13-security-releaseandroid13-s3-releaseandroid13-s2-releaseandroid13-s1-releaseandroid13-releaseandroid13-platform-releaseandroid13-gsi
Change-Id: Ie1348d0b176c53edbe38ed7ca1f14b3705ce2fbe
-rw-r--r--.cargo_vcs_info.json7
-rw-r--r--Android.bp2
-rw-r--r--Cargo.toml2
-rw-r--r--Cargo.toml.orig2
-rw-r--r--METADATA10
-rw-r--r--src/mutex.rs6
-rw-r--r--src/remutex.rs39
-rw-r--r--src/rwlock.rs111
8 files changed, 105 insertions, 74 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 58935f2..9ed45c2 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,6 @@
{
"git": {
- "sha1": "18001b819c1539c06c176c671bbe54e70b5c3d69"
- }
-}
+ "sha1": "a75875b0bf904287a9749e8eabea919b5e9dd8a9"
+ },
+ "path_in_vcs": "lock_api"
+} \ No newline at end of file
diff --git a/Android.bp b/Android.bp
index 06ca975..67d3a3b 100644
--- a/Android.bp
+++ b/Android.bp
@@ -42,7 +42,7 @@ rust_library {
host_supported: true,
crate_name: "lock_api",
cargo_env_compat: true,
- cargo_pkg_version: "0.4.5",
+ cargo_pkg_version: "0.4.6",
srcs: ["src/lib.rs"],
edition: "2018",
rustlibs: [
diff --git a/Cargo.toml b/Cargo.toml
index 4382f30..63cf8c3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,7 +12,7 @@
[package]
edition = "2018"
name = "lock_api"
-version = "0.4.5"
+version = "0.4.6"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Wrappers to create fully-featured Mutex and RwLock types. Compatible with no_std."
keywords = ["mutex", "rwlock", "lock", "no_std"]
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 96ffdfc..e6a805f 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "lock_api"
-version = "0.4.5"
+version = "0.4.6"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Wrappers to create fully-featured Mutex and RwLock types. Compatible with no_std."
license = "Apache-2.0/MIT"
diff --git a/METADATA b/METADATA
index ebfc44b..1caadde 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/lock_api/lock_api-0.4.5.crate"
+ value: "https://static.crates.io/crates/lock_api/lock_api-0.4.6.crate"
}
- version: "0.4.5"
+ version: "0.4.6"
license_type: NOTICE
last_upgrade_date {
- year: 2021
- month: 9
- day: 22
+ year: 2022
+ month: 3
+ day: 1
}
}
diff --git a/src/mutex.rs b/src/mutex.rs
index f64fc13..81c25fb 100644
--- a/src/mutex.rs
+++ b/src/mutex.rs
@@ -663,8 +663,8 @@ impl<'a, R: RawMutex + 'a, T: fmt::Display + ?Sized + 'a> fmt::Display for Mutex
unsafe impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> StableAddress for MutexGuard<'a, R, T> {}
/// An RAII mutex guard returned by the `Arc` locking operations on `Mutex`.
-///
-/// This is similar to the `MutexGuard` struct, except instead of using a reference to unlock the `Mutex` it
+///
+/// This is similar to the `MutexGuard` struct, except instead of using a reference to unlock the `Mutex` it
/// uses an `Arc<Mutex>`. This has several advantages, most notably that it has an `'static` lifetime.
#[cfg(feature = "arc_lock")]
#[must_use = "if unused the Mutex will immediately unlock"]
@@ -713,7 +713,7 @@ impl<R: RawMutexFair, T: ?Sized> ArcMutexGuard<R, T> {
// SAFETY: make sure the Arc gets it reference decremented
let mut s = ManuallyDrop::new(s);
- unsafe { ptr::drop_in_place(&mut s.mutex) };
+ unsafe { ptr::drop_in_place(&mut s.mutex) };
}
/// Temporarily unlocks the mutex to execute the given function.
diff --git a/src/remutex.rs b/src/remutex.rs
index 8493a24..dd992b4 100644
--- a/src/remutex.rs
+++ b/src/remutex.rs
@@ -401,7 +401,7 @@ impl<R: RawMutex, G: GetThreadId, T: ?Sized> ReentrantMutex<R, G, T> {
}
/// # Safety
- ///
+ ///
/// The lock must be held before calling this method.
#[cfg(feature = "arc_lock")]
#[inline]
@@ -413,7 +413,7 @@ impl<R: RawMutex, G: GetThreadId, T: ?Sized> ReentrantMutex<R, G, T> {
}
/// Acquires a reentrant mutex through an `Arc`.
- ///
+ ///
/// This method is similar to the `lock` method; however, it requires the `ReentrantMutex` to be inside of an
/// `Arc` and the resulting mutex guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
@@ -425,7 +425,7 @@ impl<R: RawMutex, G: GetThreadId, T: ?Sized> ReentrantMutex<R, G, T> {
}
/// Attempts to acquire a reentrant mutex through an `Arc`.
- ///
+ ///
/// This method is similar to the `try_lock` method; however, it requires the `ReentrantMutex` to be inside
/// of an `Arc` and the resulting mutex guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
@@ -490,12 +490,15 @@ impl<R: RawMutexTimed, G: GetThreadId, T: ?Sized> ReentrantMutex<R, G, T> {
}
/// Attempts to acquire this lock until a timeout is reached, through an `Arc`.
- ///
+ ///
/// This method is similar to the `try_lock_for` method; however, it requires the `ReentrantMutex` to be
/// inside of an `Arc` and the resulting mutex guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
#[inline]
- pub fn try_lock_arc_for(self: &Arc<Self>, timeout: R::Duration) -> Option<ArcReentrantMutexGuard<R, G, T>> {
+ pub fn try_lock_arc_for(
+ self: &Arc<Self>,
+ timeout: R::Duration,
+ ) -> Option<ArcReentrantMutexGuard<R, G, T>> {
if self.raw.try_lock_for(timeout) {
// SAFETY: locking guarantee is upheld
Some(unsafe { self.guard_arc() })
@@ -505,12 +508,15 @@ impl<R: RawMutexTimed, G: GetThreadId, T: ?Sized> ReentrantMutex<R, G, T> {
}
/// Attempts to acquire this lock until a timeout is reached, through an `Arc`.
- ///
+ ///
/// This method is similar to the `try_lock_until` method; however, it requires the `ReentrantMutex` to be
/// inside of an `Arc` and the resulting mutex guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
#[inline]
- pub fn try_lock_arc_until(self: &Arc<Self>, timeout: R::Instant) -> Option<ArcReentrantMutexGuard<R, G, T>> {
+ pub fn try_lock_arc_until(
+ self: &Arc<Self>,
+ timeout: R::Instant,
+ ) -> Option<ArcReentrantMutexGuard<R, G, T>> {
if self.raw.try_lock_until(timeout) {
// SAFETY: locking guarantee is upheld
Some(unsafe { self.guard_arc() })
@@ -736,7 +742,6 @@ impl<'a, R: RawMutexFair + 'a, G: GetThreadId + 'a, T: ?Sized + 'a>
s.remutex.raw.bump();
}
}
-
}
impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> Deref
@@ -783,9 +788,9 @@ unsafe impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> StableAdd
{
}
-/// An RAII mutex guard returned by the `Arc` locking operations on `ReentrantMutex`.
-///
-/// This is similar to the `ReentrantMutexGuard` struct, except instead of using a reference to unlock the
+/// An RAII mutex guard returned by the `Arc` locking operations on `ReentrantMutex`.
+///
+/// This is similar to the `ReentrantMutexGuard` struct, except instead of using a reference to unlock the
/// `Mutex` it uses an `Arc<ReentrantMutex>`. This has several advantages, most notably that it has an `'static`
/// lifetime.
#[cfg(feature = "arc_lock")]
@@ -821,9 +826,7 @@ impl<R: RawMutex, G: GetThreadId, T: ?Sized> ArcReentrantMutexGuard<R, G, T> {
}
#[cfg(feature = "arc_lock")]
-impl<R: RawMutexFair, G: GetThreadId, T: ?Sized>
- ArcReentrantMutexGuard<R, G, T>
-{
+impl<R: RawMutexFair, G: GetThreadId, T: ?Sized> ArcReentrantMutexGuard<R, G, T> {
/// Unlocks the mutex using a fair unlock protocol.
///
/// This is functionally identical to the `unlock_fair` method on [`ReentrantMutexGuard`].
@@ -868,9 +871,7 @@ impl<R: RawMutexFair, G: GetThreadId, T: ?Sized>
}
#[cfg(feature = "arc_lock")]
-impl<R: RawMutex, G: GetThreadId, T: ?Sized> Deref
- for ArcReentrantMutexGuard<R, G, T>
-{
+impl<R: RawMutex, G: GetThreadId, T: ?Sized> Deref for ArcReentrantMutexGuard<R, G, T> {
type Target = T;
#[inline]
fn deref(&self) -> &T {
@@ -879,9 +880,7 @@ impl<R: RawMutex, G: GetThreadId, T: ?Sized> Deref
}
#[cfg(feature = "arc_lock")]
-impl<R: RawMutex, G: GetThreadId, T: ?Sized> Drop
- for ArcReentrantMutexGuard<R, G, T>
-{
+impl<R: RawMutex, G: GetThreadId, T: ?Sized> Drop for ArcReentrantMutexGuard<R, G, T> {
#[inline]
fn drop(&mut self) {
// Safety: A ReentrantMutexGuard always holds the lock.
diff --git a/src/rwlock.rs b/src/rwlock.rs
index c404934..9bfa1da 100644
--- a/src/rwlock.rs
+++ b/src/rwlock.rs
@@ -84,6 +84,18 @@ pub unsafe trait RawRwLock {
}
!acquired_lock
}
+
+ /// Check if this `RwLock` is currently exclusively locked.
+ fn is_locked_exclusive(&self) -> bool {
+ let acquired_lock = self.try_lock_shared();
+ if acquired_lock {
+ // Safety: A shared lock was successfully acquired above.
+ unsafe {
+ self.unlock_shared();
+ }
+ }
+ !acquired_lock
+ }
}
/// Additional methods for RwLocks which support fair unlocking.
@@ -502,6 +514,12 @@ impl<R: RawRwLock, T: ?Sized> RwLock<R, T> {
self.raw.is_locked()
}
+ /// Check if this `RwLock` is currently exclusively locked.
+ #[inline]
+ pub fn is_locked_exclusive(&self) -> bool {
+ self.raw.is_locked_exclusive()
+ }
+
/// Forcibly unlocks a read lock.
///
/// This is useful when combined with `mem::forget` to hold a lock without
@@ -590,7 +608,7 @@ impl<R: RawRwLock, T: ?Sized> RwLock<R, T> {
}
/// Locks this `RwLock` with read access, through an `Arc`.
- ///
+ ///
/// This method is similar to the `read` method; however, it requires the `RwLock` to be inside of an `Arc`
/// and the resulting read guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
@@ -602,8 +620,8 @@ impl<R: RawRwLock, T: ?Sized> RwLock<R, T> {
}
/// Attempts to lock this `RwLock` with read access, through an `Arc`.
- ///
- /// This method is similar to the `try_read` method; however, it requires the `RwLock` to be inside of an
+ ///
+ /// This method is similar to the `try_read` method; however, it requires the `RwLock` to be inside of an
/// `Arc` and the resulting read guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
#[inline]
@@ -617,7 +635,7 @@ impl<R: RawRwLock, T: ?Sized> RwLock<R, T> {
}
/// Locks this `RwLock` with write access, through an `Arc`.
- ///
+ ///
/// This method is similar to the `write` method; however, it requires the `RwLock` to be inside of an `Arc`
/// and the resulting write guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
@@ -629,8 +647,8 @@ impl<R: RawRwLock, T: ?Sized> RwLock<R, T> {
}
/// Attempts to lock this `RwLock` with writ access, through an `Arc`.
- ///
- /// This method is similar to the `try_write` method; however, it requires the `RwLock` to be inside of an
+ ///
+ /// This method is similar to the `try_write` method; however, it requires the `RwLock` to be inside of an
/// `Arc` and the resulting write guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
#[inline]
@@ -744,12 +762,15 @@ impl<R: RawRwLockTimed, T: ?Sized> RwLock<R, T> {
}
/// Attempts to acquire this `RwLock` with read access until a timeout is reached, through an `Arc`.
- ///
+ ///
/// This method is similar to the `try_read_for` method; however, it requires the `RwLock` to be inside of an
/// `Arc` and the resulting read guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
#[inline]
- pub fn try_read_arc_for(self: &Arc<Self>, timeout: R::Duration) -> Option<ArcRwLockReadGuard<R, T>> {
+ pub fn try_read_arc_for(
+ self: &Arc<Self>,
+ timeout: R::Duration,
+ ) -> Option<ArcRwLockReadGuard<R, T>> {
if self.raw.try_lock_shared_for(timeout) {
// SAFETY: locking guarantee is upheld
Some(unsafe { self.read_guard_arc() })
@@ -759,12 +780,15 @@ impl<R: RawRwLockTimed, T: ?Sized> RwLock<R, T> {
}
/// Attempts to acquire this `RwLock` with read access until a timeout is reached, through an `Arc`.
- ///
+ ///
/// This method is similar to the `try_read_until` method; however, it requires the `RwLock` to be inside of
/// an `Arc` and the resulting read guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
#[inline]
- pub fn try_read_arc_until(self: &Arc<Self>, timeout: R::Instant) -> Option<ArcRwLockReadGuard<R, T>> {
+ pub fn try_read_arc_until(
+ self: &Arc<Self>,
+ timeout: R::Instant,
+ ) -> Option<ArcRwLockReadGuard<R, T>> {
if self.raw.try_lock_shared_until(timeout) {
// SAFETY: locking guarantee is upheld
Some(unsafe { self.read_guard_arc() })
@@ -774,12 +798,15 @@ impl<R: RawRwLockTimed, T: ?Sized> RwLock<R, T> {
}
/// Attempts to acquire this `RwLock` with write access until a timeout is reached, through an `Arc`.
- ///
+ ///
/// This method is similar to the `try_write_for` method; however, it requires the `RwLock` to be inside of
/// an `Arc` and the resulting write guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
#[inline]
- pub fn try_write_arc_for(self: &Arc<Self>, timeout: R::Duration) -> Option<ArcRwLockWriteGuard<R, T>> {
+ pub fn try_write_arc_for(
+ self: &Arc<Self>,
+ timeout: R::Duration,
+ ) -> Option<ArcRwLockWriteGuard<R, T>> {
if self.raw.try_lock_exclusive_for(timeout) {
// SAFETY: locking guarantee is upheld
Some(unsafe { self.write_guard_arc() })
@@ -789,12 +816,15 @@ impl<R: RawRwLockTimed, T: ?Sized> RwLock<R, T> {
}
/// Attempts to acquire this `RwLock` with read access until a timeout is reached, through an `Arc`.
- ///
+ ///
/// This method is similar to the `try_write_until` method; however, it requires the `RwLock` to be inside of
/// an `Arc` and the resulting read guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
#[inline]
- pub fn try_write_arc_until(self: &Arc<Self>, timeout: R::Instant) -> Option<ArcRwLockWriteGuard<R, T>> {
+ pub fn try_write_arc_until(
+ self: &Arc<Self>,
+ timeout: R::Instant,
+ ) -> Option<ArcRwLockWriteGuard<R, T>> {
if self.raw.try_lock_exclusive_until(timeout) {
// SAFETY: locking guarantee is upheld
Some(unsafe { self.write_guard_arc() })
@@ -848,7 +878,7 @@ impl<R: RawRwLockRecursive, T: ?Sized> RwLock<R, T> {
}
/// Locks this `RwLock` with shared read access, through an `Arc`.
- ///
+ ///
/// This method is similar to the `read_recursive` method; however, it requires the `RwLock` to be inside of
/// an `Arc` and the resulting read guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
@@ -860,7 +890,7 @@ impl<R: RawRwLockRecursive, T: ?Sized> RwLock<R, T> {
}
/// Attempts to lock this `RwLock` with shared read access, through an `Arc`.
- ///
+ ///
/// This method is similar to the `try_read_recursive` method; however, it requires the `RwLock` to be inside
/// of an `Arc` and the resulting read guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
@@ -924,7 +954,10 @@ impl<R: RawRwLockRecursiveTimed, T: ?Sized> RwLock<R, T> {
/// inside of an `Arc` and the resulting read guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
#[inline]
- pub fn try_read_arc_recursive_for(self: &Arc<Self>, timeout: R::Duration) -> Option<ArcRwLockReadGuard<R, T>> {
+ pub fn try_read_arc_recursive_for(
+ self: &Arc<Self>,
+ timeout: R::Duration,
+ ) -> Option<ArcRwLockReadGuard<R, T>> {
if self.raw.try_lock_shared_recursive_for(timeout) {
// SAFETY: locking guarantee is upheld
Some(unsafe { self.read_guard_arc() })
@@ -939,7 +972,10 @@ impl<R: RawRwLockRecursiveTimed, T: ?Sized> RwLock<R, T> {
/// inside of an `Arc` and the resulting read guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
#[inline]
- pub fn try_read_arc_recursive_until(self: &Arc<Self>, timeout: R::Instant) -> Option<ArcRwLockReadGuard<R, T>> {
+ pub fn try_read_arc_recursive_until(
+ self: &Arc<Self>,
+ timeout: R::Instant,
+ ) -> Option<ArcRwLockReadGuard<R, T>> {
if self.raw.try_lock_shared_recursive_until(timeout) {
// SAFETY: locking guarantee is upheld
Some(unsafe { self.read_guard_arc() })
@@ -995,19 +1031,19 @@ impl<R: RawRwLockUpgrade, T: ?Sized> RwLock<R, T> {
}
/// # Safety
- ///
+ ///
/// The lock must be held when calling this method.
#[cfg(feature = "arc_lock")]
#[inline]
unsafe fn upgradable_guard_arc(self: &Arc<Self>) -> ArcRwLockUpgradableReadGuard<R, T> {
ArcRwLockUpgradableReadGuard {
rwlock: self.clone(),
- marker: PhantomData
+ marker: PhantomData,
}
}
/// Locks this `RwLock` with upgradable read access, through an `Arc`.
- ///
+ ///
/// This method is similar to the `upgradable_read` method; however, it requires the `RwLock` to be
/// inside of an `Arc` and the resulting read guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
@@ -1019,7 +1055,7 @@ impl<R: RawRwLockUpgrade, T: ?Sized> RwLock<R, T> {
}
/// Attempts to lock this `RwLock` with upgradable read access, through an `Arc`.
- ///
+ ///
/// This method is similar to the `try_upgradable_read` method; however, it requires the `RwLock` to be
/// inside of an `Arc` and the resulting read guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
@@ -1074,7 +1110,7 @@ impl<R: RawRwLockUpgradeTimed, T: ?Sized> RwLock<R, T> {
}
/// Attempts to lock this `RwLock` with upgradable access until a timeout is reached, through an `Arc`.
- ///
+ ///
/// This method is similar to the `try_upgradable_read_for` method; however, it requires the `RwLock` to be
/// inside of an `Arc` and the resulting read guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
@@ -1092,7 +1128,7 @@ impl<R: RawRwLockUpgradeTimed, T: ?Sized> RwLock<R, T> {
}
/// Attempts to lock this `RwLock` with upgradable access until a timeout is reached, through an `Arc`.
- ///
+ ///
/// This method is similar to the `try_upgradable_read_until` method; however, it requires the `RwLock` to be
/// inside of an `Arc` and the resulting read guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
@@ -1318,9 +1354,9 @@ impl<'a, R: RawRwLock + 'a, T: fmt::Display + ?Sized + 'a> fmt::Display
#[cfg(feature = "owning_ref")]
unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> StableAddress for RwLockReadGuard<'a, R, T> {}
-/// An RAII rwlock guard returned by the `Arc` locking operations on `RwLock`.
-///
-/// This is similar to the `RwLockReadGuard` struct, except instead of using a reference to unlock the `RwLock`
+/// An RAII rwlock guard returned by the `Arc` locking operations on `RwLock`.
+///
+/// This is similar to the `RwLockReadGuard` struct, except instead of using a reference to unlock the `RwLock`
/// it uses an `Arc<RwLock>`. This has several advantages, most notably that it has an `'static` lifetime.
#[cfg(feature = "arc_lock")]
#[must_use = "if unused the RwLock will immediately unlock"]
@@ -1426,9 +1462,7 @@ impl<R: RawRwLock, T: fmt::Debug + ?Sized> fmt::Debug for ArcRwLockReadGuard<R,
}
#[cfg(feature = "arc_lock")]
-impl<R: RawRwLock, T: fmt::Display + ?Sized> fmt::Display
- for ArcRwLockReadGuard<R, T>
-{
+impl<R: RawRwLock, T: fmt::Display + ?Sized> fmt::Display for ArcRwLockReadGuard<R, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
(**self).fmt(f)
}
@@ -1655,8 +1689,8 @@ impl<'a, R: RawRwLock + 'a, T: fmt::Display + ?Sized + 'a> fmt::Display
#[cfg(feature = "owning_ref")]
unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> StableAddress for RwLockWriteGuard<'a, R, T> {}
-/// An RAII rwlock guard returned by the `Arc` locking operations on `RwLock`.
-/// This is similar to the `RwLockWriteGuard` struct, except instead of using a reference to unlock the `RwLock`
+/// An RAII rwlock guard returned by the `Arc` locking operations on `RwLock`.
+/// This is similar to the `RwLockWriteGuard` struct, except instead of using a reference to unlock the `RwLock`
/// it uses an `Arc<RwLock>`. This has several advantages, most notably that it has an `'static` lifetime.
#[cfg(feature = "arc_lock")]
#[must_use = "if unused the RwLock will immediately unlock"]
@@ -1770,7 +1804,7 @@ impl<R: RawRwLockFair, T: ?Sized> ArcRwLockWriteGuard<R, T> {
/// Temporarily yields the `RwLock` to a waiting thread if there is one.
///
- /// This method is functionally equivalent to the `bump` method on [`RwLockWriteGuard`].
+ /// This method is functionally equivalent to the `bump` method on [`RwLockWriteGuard`].
#[inline]
pub fn bump(s: &mut Self) {
// Safety: An RwLockWriteGuard always holds an exclusive lock.
@@ -1816,9 +1850,7 @@ impl<R: RawRwLock, T: fmt::Debug + ?Sized> fmt::Debug for ArcRwLockWriteGuard<R,
}
#[cfg(feature = "arc_lock")]
-impl<R: RawRwLock, T: fmt::Display + ?Sized> fmt::Display
- for ArcRwLockWriteGuard<R, T>
-{
+impl<R: RawRwLock, T: fmt::Display + ?Sized> fmt::Display for ArcRwLockWriteGuard<R, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
(**self).fmt(f)
}
@@ -2059,7 +2091,7 @@ unsafe impl<'a, R: RawRwLockUpgrade + 'a, T: ?Sized + 'a> StableAddress
/// An RAII rwlock guard returned by the `Arc` locking operations on `RwLock`.
/// This is similar to the `RwLockUpgradableReadGuard` struct, except instead of using a reference to unlock the
-/// `RwLock` it uses an `Arc<RwLock>`. This has several advantages, most notably that it has an `'static`
+/// `RwLock` it uses an `Arc<RwLock>`. This has several advantages, most notably that it has an `'static`
/// lifetime.
#[cfg(feature = "arc_lock")]
#[must_use = "if unused the RwLock will immediately unlock"]
@@ -2069,7 +2101,7 @@ pub struct ArcRwLockUpgradableReadGuard<R: RawRwLockUpgrade, T: ?Sized> {
}
#[cfg(feature = "arc_lock")]
-impl<R: RawRwLockUpgrade , T: ?Sized> ArcRwLockUpgradableReadGuard<R, T> {
+impl<R: RawRwLockUpgrade, T: ?Sized> ArcRwLockUpgradableReadGuard<R, T> {
/// Returns a reference to the rwlock, contained in its original `Arc`.
pub fn rwlock(s: &Self) -> &Arc<RwLock<R, T>> {
&s.rwlock
@@ -2144,7 +2176,7 @@ impl<R: RawRwLockUpgradeFair, T: ?Sized> ArcRwLockUpgradableReadGuard<R, T> {
// SAFETY: make sure we decrement the refcount properly
let mut s = ManuallyDrop::new(s);
- unsafe { ptr::drop_in_place(&mut s.rwlock) };
+ unsafe { ptr::drop_in_place(&mut s.rwlock) };
}
/// Temporarily unlocks the `RwLock` to execute the given function.
@@ -2291,7 +2323,6 @@ impl<R: RawRwLockUpgrade, T: fmt::Display + ?Sized> fmt::Display
}
}
-
/// An RAII read lock guard returned by `RwLockReadGuard::map`, which can point to a
/// subfield of the protected data.
///