Bug 1716518 - Upgrade lock_api to v0.4.4. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D117810
This commit is contained in:
Mike Hommey 2021-06-15 22:04:49 +00:00
parent b8e1c2ab28
commit 91338fb7f7
7 changed files with 23 additions and 12 deletions

4
Cargo.lock generated
View File

@ -2819,9 +2819,9 @@ dependencies = [
[[package]]
name = "lock_api"
version = "0.4.1"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28247cc5a5be2f05fbcd76dd0cf2c7d3b5400cb978a28042abcd4fa0b3f8261c"
checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb"
dependencies = [
"scopeguard",
]

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"1bf17c743b2b6e0dc27f4ff7fd91332fd68dda0dd3ef6896b3adff501698c535","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","src/lib.rs":"dc65d2d422467d16ab2bd64a5ed0243a12774e4a25684bb805e8fc4c454a9879","src/mutex.rs":"eaff7ee683e87dad533abbfdf42a18e93b6811b724586084e29caf0001453af0","src/remutex.rs":"1049b5c824a1f2df4e0ed348fbe8a9d5697f9ad4779b174ad7a02610d23bcf7c","src/rwlock.rs":"c9fea399f386ef818cc69b3269976ca656cd8787edbe84d45d40596a83acba13"},"package":"28247cc5a5be2f05fbcd76dd0cf2c7d3b5400cb978a28042abcd4fa0b3f8261c"}
{"files":{"Cargo.toml":"e63c80c2e3535c415fca3153038b4682b0edd893dfa32e4b89300393f57b1e33","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","src/lib.rs":"f195084467e1877610535da9e51ef1fd6f190550c637d7363c1cfa8ecf99ad83","src/mutex.rs":"db7f0dcb09fc5aaab2b04d6eac7b80b799da8fdb669fa43ddbb7007663760782","src/remutex.rs":"83f6704348eb5052364c98aea2c5eaa621b22e3f4b03c4c130069496f7825595","src/rwlock.rs":"6639e140c50ee81e212647e5a2596c0e247a0a062ee8471c79d268c1280c7330"},"package":"0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb"}

View File

@ -13,7 +13,7 @@
[package]
edition = "2018"
name = "lock_api"
version = "0.4.1"
version = "0.4.4"
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"]

View File

@ -88,7 +88,7 @@
#![no_std]
#![warn(missing_docs)]
#![warn(rust_2018_idioms)]
#![cfg_attr(feature = "nightly", feature(const_fn))]
#![cfg_attr(feature = "nightly", feature(const_fn_trait_bound))]
#[macro_use]
extern crate scopeguard;
@ -99,6 +99,8 @@ pub struct GuardSend(());
/// Marker type which indicates that the Guard type for a lock is not `Send`.
pub struct GuardNoSend(*mut ());
unsafe impl Sync for GuardNoSend {}
mod mutex;
pub use crate::mutex::*;

View File

@ -601,7 +601,7 @@ unsafe impl<'a, R: RawMutex + Sync + 'a, T: ?Sized + Sync + 'a> Sync
for MappedMutexGuard<'a, R, T>
{
}
unsafe impl<'a, R: RawMutex + 'a, T: ?Sized + 'a> Send for MappedMutexGuard<'a, R, T> where
unsafe impl<'a, R: RawMutex + 'a, T: ?Sized + Send + 'a> Send for MappedMutexGuard<'a, R, T> where
R::GuardMarker: Send
{
}

View File

@ -135,6 +135,13 @@ impl<R: RawMutex, G: GetThreadId> RawReentrantMutex<R, G> {
pub fn is_locked(&self) -> bool {
self.mutex.is_locked()
}
/// Checks whether the mutex is currently held by the current thread.
#[inline]
pub fn is_owned_by_current_thread(&self) -> bool {
let id = self.get_thread_id.nonzero_thread_id().get();
self.owner.load(Ordering::Relaxed) == id
}
}
impl<R: RawMutexFair, G: GetThreadId> RawReentrantMutex<R, G> {
@ -333,6 +340,12 @@ impl<R: RawMutex, G: GetThreadId, T: ?Sized> ReentrantMutex<R, G, T> {
self.raw.is_locked()
}
/// Checks whether the mutex is currently held by the current thread.
#[inline]
pub fn is_owned_by_current_thread(&self) -> bool {
self.raw.is_owned_by_current_thread()
}
/// Forcibly unlocks the mutex.
///
/// This is useful when combined with `mem::forget` to hold a lock without

View File

@ -875,8 +875,6 @@ pub struct RwLockReadGuard<'a, R: RawRwLock, T: ?Sized> {
marker: PhantomData<(&'a T, R::GuardMarker)>,
}
unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + Sync + 'a> Sync for RwLockReadGuard<'a, R, T> {}
impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> RwLockReadGuard<'a, R, T> {
/// Returns a reference to the original reader-writer lock object.
pub fn rwlock(s: &Self) -> &'a RwLock<R, T> {
@ -1051,8 +1049,6 @@ pub struct RwLockWriteGuard<'a, R: RawRwLock, T: ?Sized> {
marker: PhantomData<(&'a mut T, R::GuardMarker)>,
}
unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + Sync + 'a> Sync for RwLockWriteGuard<'a, R, T> {}
impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> RwLockWriteGuard<'a, R, T> {
/// Returns a reference to the original reader-writer lock object.
pub fn rwlock(s: &Self) -> &'a RwLock<R, T> {
@ -1514,7 +1510,7 @@ pub struct MappedRwLockReadGuard<'a, R: RawRwLock, T: ?Sized> {
}
unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + Sync + 'a> Sync for MappedRwLockReadGuard<'a, R, T> {}
unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Send for MappedRwLockReadGuard<'a, R, T> where
unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + Sync + 'a> Send for MappedRwLockReadGuard<'a, R, T> where
R::GuardMarker: Send
{
}
@ -1652,7 +1648,7 @@ unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + Sync + 'a> Sync
for MappedRwLockWriteGuard<'a, R, T>
{
}
unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> Send for MappedRwLockWriteGuard<'a, R, T> where
unsafe impl<'a, R: RawRwLock + 'a, T: ?Sized + Send + 'a> Send for MappedRwLockWriteGuard<'a, R, T> where
R::GuardMarker: Send
{
}