diff options
author | Joel Galenson <jgalenson@google.com> | 2021-05-20 12:56:10 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-05-20 12:56:10 +0000 |
commit | 3441188bef91bd23423a05310aa10e6ca7d4a08d (patch) | |
tree | 26056552789278d6ffd95d6cbefb8f9e6973a42a | |
parent | 81d0e1d3890bded371d5af33077173cb19a1b006 (diff) | |
parent | 94091c9ae2ca9b7315b3ef6f77723abc139be940 (diff) | |
download | lock_api-3441188bef91bd23423a05310aa10e6ca7d4a08d.tar.gz |
Upgrade rust/crates/lock_api to 0.4.4 am: 94091c9ae2android-s-beta-5android-s-beta-4android-s-beta-3android-s-beta-5android-s-beta-4
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/lock_api/+/1712770
Change-Id: I1f88b202e84feb571639c5eb205e1851510d2d5a
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 4 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | Cargo.toml.orig | 2 | ||||
-rw-r--r-- | METADATA | 10 | ||||
-rw-r--r-- | TEST_MAPPING | 2 | ||||
-rw-r--r-- | src/lib.rs | 2 | ||||
-rw-r--r-- | src/remutex.rs | 13 |
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" } } @@ -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 { @@ -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" @@ -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": [ { @@ -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 |