• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/core


Commit MetaInfo

修订版8105c3118939f36f93f5611a21172d3389aad195 (tree)
时间2019-03-30 07:51:21
作者Mikhail Naganov <mnaganov@goog...>
Commiterandroid-build-merger

Log Message

Merge "libutils: Fix thread safety annotations in Mutex"
am: f8fe94e546

Change-Id: Ied4eab63acfdcd460de8b54b603180e9dd219478

更改概述

差异

--- a/libutils/Mutex_test.cpp
+++ b/libutils/Mutex_test.cpp
@@ -29,4 +29,20 @@ TEST(Mutex, compile) {
2929 android::Mutex::Autolock _l(mLock);
3030 i = 0;
3131 modifyLockedVariable();
32-}
\ No newline at end of file
32+}
33+
34+TEST(Mutex, tryLock) {
35+ if (mLock.tryLock() != 0) {
36+ return;
37+ }
38+ mLock.unlock();
39+}
40+
41+#if defined(__ANDROID__)
42+TEST(Mutex, timedLock) {
43+ if (mLock.timedLock(1) != 0) {
44+ return;
45+ }
46+ mLock.unlock();
47+}
48+#endif
--- a/libutils/include/utils/Mutex.h
+++ b/libutils/include/utils/Mutex.h
@@ -108,7 +108,7 @@ class CAPABILITY("mutex") Mutex {
108108 void unlock() RELEASE();
109109
110110 // lock if possible; returns 0 on success, error otherwise
111- status_t tryLock() TRY_ACQUIRE(true);
111+ status_t tryLock() TRY_ACQUIRE(0);
112112
113113 #if defined(__ANDROID__)
114114 // Lock the mutex, but don't wait longer than timeoutNs (relative time).
@@ -122,7 +122,7 @@ class CAPABILITY("mutex") Mutex {
122122 // which is subject to NTP adjustments, and includes time during suspend,
123123 // so a timeout may occur even though no processes could run.
124124 // Not holding a partial wakelock may lead to a system suspend.
125- status_t timedLock(nsecs_t timeoutNs) TRY_ACQUIRE(true);
125+ status_t timedLock(nsecs_t timeoutNs) TRY_ACQUIRE(0);
126126 #endif
127127
128128 // Manages the mutex automatically. It'll be locked when Autolock is