system/core
リビジョン | 8105c3118939f36f93f5611a21172d3389aad195 (tree) |
---|---|
日時 | 2019-03-30 07:51:21 |
作者 | Mikhail Naganov <mnaganov@goog...> |
コミッター | android-build-merger |
Merge "libutils: Fix thread safety annotations in Mutex"
am: f8fe94e546
Change-Id: Ied4eab63acfdcd460de8b54b603180e9dd219478
@@ -29,4 +29,20 @@ TEST(Mutex, compile) { | ||
29 | 29 | android::Mutex::Autolock _l(mLock); |
30 | 30 | i = 0; |
31 | 31 | 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 |
@@ -108,7 +108,7 @@ class CAPABILITY("mutex") Mutex { | ||
108 | 108 | void unlock() RELEASE(); |
109 | 109 | |
110 | 110 | // lock if possible; returns 0 on success, error otherwise |
111 | - status_t tryLock() TRY_ACQUIRE(true); | |
111 | + status_t tryLock() TRY_ACQUIRE(0); | |
112 | 112 | |
113 | 113 | #if defined(__ANDROID__) |
114 | 114 | // Lock the mutex, but don't wait longer than timeoutNs (relative time). |
@@ -122,7 +122,7 @@ class CAPABILITY("mutex") Mutex { | ||
122 | 122 | // which is subject to NTP adjustments, and includes time during suspend, |
123 | 123 | // so a timeout may occur even though no processes could run. |
124 | 124 | // 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); | |
126 | 126 | #endif |
127 | 127 | |
128 | 128 | // Manages the mutex automatically. It'll be locked when Autolock is |