summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Galenson <jgalenson@google.com>2021-05-20 13:11:23 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-05-20 13:11:23 +0000
commit674b7a2427b5336a8f10b4eaef1bbd238e4f0698 (patch)
tree26056552789278d6ffd95d6cbefb8f9e6973a42a
parent4056291abc17bda6a3944cc7fdb76a7c38c1fad4 (diff)
parent3441188bef91bd23423a05310aa10e6ca7d4a08d (diff)
downloadlock_api-674b7a2427b5336a8f10b4eaef1bbd238e4f0698.tar.gz
Upgrade rust/crates/lock_api to 0.4.4 am: 94091c9ae2 am: 3441188bef
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/lock_api/+/1712770 Change-Id: I60ae099f35bf6e5682467edb3f3af1a02d745455
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Android.bp4
-rw-r--r--Cargo.toml2
-rw-r--r--Cargo.toml.orig2
-rw-r--r--METADATA10
-rw-r--r--TEST_MAPPING2
-rw-r--r--src/lib.rs2
-rw-r--r--src/remutex.rs13
8 files changed, 27 insertions, 10 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index e1a0b04..6ffdcd3 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
{
"git": {
- "sha1": "86969fd7baf94312520e0b5a5f3b0861a0fd411b"
+ "sha1": "0dcf7ce54a4f8ca76367c1bd2eeb48644b416d84"
}
}
diff --git a/Android.bp b/Android.bp
index cc03613..74f015c 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,4 +1,5 @@
// This file is generated by cargo2android.py --run --device --dependencies --tests.
+// Do not modify this file as changes will be overridden on upgrade.
package {
default_applicable_licenses: ["external_rust_crates_lock_api_license"],
@@ -62,6 +63,9 @@ rust_defaults {
rust_test_host {
name: "lock_api_host_test_src_lib",
defaults: ["lock_api_defaults"],
+ test_options: {
+ unit_test: true,
+ },
}
rust_test {
diff --git a/Cargo.toml b/Cargo.toml
index cdc5b16..213250b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@
[package]
edition = "2018"
name = "lock_api"
-version = "0.4.2"
+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"]
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 9e884a4..55b5c35 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "lock_api"
-version = "0.4.2"
+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."
license = "Apache-2.0/MIT"
diff --git a/METADATA b/METADATA
index a684451..efad828 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.2.crate"
+ value: "https://static.crates.io/crates/lock_api/lock_api-0.4.4.crate"
}
- version: "0.4.2"
+ version: "0.4.4"
license_type: NOTICE
last_upgrade_date {
- year: 2020
- month: 11
- day: 17
+ year: 2021
+ month: 5
+ day: 19
}
}
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 738f5ec..d3f0059 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -1,4 +1,4 @@
-// Generated by cargo2android.py for tests in Android.bp
+// Generated by update_crate_tests.py for tests that depend on this crate.
{
"presubmit": [
{
diff --git a/src/lib.rs b/src/lib.rs
index d9097a3..6d58135 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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;
diff --git a/src/remutex.rs b/src/remutex.rs
index 09833b0..b49ec6c 100644
--- a/src/remutex.rs
+++ b/src/remutex.rs
@@ -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