Bug 1773399 - Update lock_api to 0.4.7. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D148713
This commit is contained in:
Mike Hommey 2022-06-09 20:05:43 +00:00
Родитель 8c504b904a
Коммит 2e53b575b3
9 изменённых файлов: 139 добавлений и 81 удалений

5
Cargo.lock сгенерированный
Просмотреть файл

@ -3088,10 +3088,11 @@ dependencies = [
[[package]]
name = "lock_api"
version = "0.4.5"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109"
checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53"
dependencies = [
"autocfg",
"scopeguard",
]

Просмотреть файл

@ -878,7 +878,7 @@ version = "0.11.2"
criteria = "safe-to-deploy"
[[unaudited.lock_api]]
version = "0.4.5"
version = "0.4.7"
criteria = "safe-to-deploy"
[[unaudited.log]]

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"480236b01449b56dad945652b3af7f73faea452dca132da3f1c90ba3ca4f984c","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","src/lib.rs":"32992cb77fba83d77e979e328953ce3da21b4005d595857f006c8bd65fb6a9ee","src/mutex.rs":"789106fe52c17b706bac5b69ef1cb656d4cef1ce4ef147872d78504dad307705","src/remutex.rs":"03708cd1aa5b982ce278c7b3ef7b97a89253eb92dc96d229ecb1602ff8373b38","src/rwlock.rs":"242db97a58018101dab370f2d0551a4172f15bc5385ecd283bfc37d11891d83b"},"package":"712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109"}
{"files":{"Cargo.toml":"f0fb3e65549d1353e2e199977db7825c29721bbeb71dee9bb3905437dd444dce","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","build.rs":"af84139c71d151adead0b4398c394a7dd16087bb2db44b14a0ed970ce868a6c6","src/lib.rs":"7b67c3b69c1b5e97248afe0f6c3bc353c793ed1ce4a5d5177e63f3f05d79c63b","src/mutex.rs":"dc4131ebf73e0474948d1849934ad5156e4a3dbd55f6881e60fd6c0acb6aa861","src/remutex.rs":"659454e66fa72e678e0aa1b83151c81c90321368dc6f4c31315230b969d4936e","src/rwlock.rs":"4f35072ca1fb476089d1548c40af775564bb7e763f86ec41a2190f8c659593cc"},"package":"327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53"}

20
third_party/rust/lock_api/Cargo.toml поставляемый
Просмотреть файл

@ -12,13 +12,22 @@
[package]
edition = "2018"
name = "lock_api"
version = "0.4.5"
version = "0.4.7"
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"]
categories = ["concurrency", "no-std"]
license = "Apache-2.0/MIT"
keywords = [
"mutex",
"rwlock",
"lock",
"no_std",
]
categories = [
"concurrency",
"no-std",
]
license = "MIT OR Apache-2.0"
repository = "https://github.com/Amanieu/parking_lot"
[dependencies.owning_ref]
version = "0.4.1"
optional = true
@ -32,6 +41,9 @@ version = "1.0.126"
optional = true
default-features = false
[build-dependencies.autocfg]
version = "1.1.0"
[features]
arc_lock = []
nightly = []

7
third_party/rust/lock_api/build.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,7 @@
fn main() {
let cfg = autocfg::new();
if cfg.probe_rustc_version(1, 61) {
println!("cargo:rustc-cfg=has_const_fn_trait_bound");
}
}

3
third_party/rust/lock_api/src/lib.rs поставляемый
Просмотреть файл

@ -84,13 +84,10 @@
//! - `owning_ref`: Allows your lock types to be used with the `owning_ref` crate.
//! - `arc_lock`: Enables locking from an `Arc`. This enables types such as `ArcMutexGuard`. Note that this
//! requires the `alloc` crate to be present.
//! - `nightly`: Enables nightly-only features. At the moment the only such
//! feature is `const fn` constructors for lock types.
#![no_std]
#![warn(missing_docs)]
#![warn(rust_2018_idioms)]
#![cfg_attr(feature = "nightly", feature(const_fn_trait_bound))]
#[macro_use]
extern crate scopeguard;

21
third_party/rust/lock_api/src/mutex.rs поставляемый
Просмотреть файл

@ -149,7 +149,7 @@ unsafe impl<R: RawMutex + Sync, T: ?Sized + Send> Sync for Mutex<R, T> {}
impl<R: RawMutex, T> Mutex<R, T> {
/// Creates a new mutex in an unlocked state ready for use.
#[cfg(feature = "nightly")]
#[cfg(has_const_fn_trait_bound)]
#[inline]
pub const fn new(val: T) -> Mutex<R, T> {
Mutex {
@ -159,7 +159,7 @@ impl<R: RawMutex, T> Mutex<R, T> {
}
/// Creates a new mutex in an unlocked state ready for use.
#[cfg(not(feature = "nightly"))]
#[cfg(not(has_const_fn_trait_bound))]
#[inline]
pub fn new(val: T) -> Mutex<R, T> {
Mutex {
@ -565,6 +565,17 @@ impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> MutexGuard<'a, R, T> {
defer!(s.mutex.raw.lock());
f()
}
/// Leaks the mutex guard and returns a mutable reference to the data
/// protected by the mutex.
///
/// This will leave the `Mutex` in a locked state.
#[inline]
pub fn leak(s: Self) -> &'a mut T {
let r = unsafe { &mut *s.mutex.data.get() };
mem::forget(s);
r
}
}
impl<'a, R: RawMutexFair + 'a, T: ?Sized + 'a> MutexGuard<'a, R, T> {
@ -663,8 +674,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 +724,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.

43
third_party/rust/lock_api/src/remutex.rs поставляемый
Просмотреть файл

@ -230,7 +230,7 @@ unsafe impl<R: RawMutex + Sync, G: GetThreadId + Sync, T: ?Sized + Send> Sync
impl<R: RawMutex, G: GetThreadId, T> ReentrantMutex<R, G, T> {
/// Creates a new reentrant mutex in an unlocked state ready for use.
#[cfg(feature = "nightly")]
#[cfg(has_const_fn_trait_bound)]
#[inline]
pub const fn new(val: T) -> ReentrantMutex<R, G, T> {
ReentrantMutex {
@ -245,7 +245,7 @@ impl<R: RawMutex, G: GetThreadId, T> ReentrantMutex<R, G, T> {
}
/// Creates a new reentrant mutex in an unlocked state ready for use.
#[cfg(not(feature = "nightly"))]
#[cfg(not(has_const_fn_trait_bound))]
#[inline]
pub fn new(val: T) -> ReentrantMutex<R, G, T> {
ReentrantMutex {
@ -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.

117
third_party/rust/lock_api/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.
@ -354,7 +366,7 @@ unsafe impl<R: RawRwLock + Sync, T: ?Sized + Send + Sync> Sync for RwLock<R, T>
impl<R: RawRwLock, T> RwLock<R, T> {
/// Creates a new instance of an `RwLock<T>` which is unlocked.
#[cfg(feature = "nightly")]
#[cfg(has_const_fn_trait_bound)]
#[inline]
pub const fn new(val: T) -> RwLock<R, T> {
RwLock {
@ -364,7 +376,7 @@ impl<R: RawRwLock, T> RwLock<R, T> {
}
/// Creates a new instance of an `RwLock<T>` which is unlocked.
#[cfg(not(feature = "nightly"))]
#[cfg(not(has_const_fn_trait_bound))]
#[inline]
pub fn new(val: T) -> RwLock<R, T> {
RwLock {
@ -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,9 +890,9 @@ 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.
/// of an `Arc` and the resulting read guard has no lifetime requirements.
#[cfg(feature = "arc_lock")]
#[inline]
pub fn try_read_recursive_arc(self: &Arc<Self>) -> Option<ArcRwLockReadGuard<R, T>> {
@ -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.
///