Loading libutils/Mutex_test.cpp +17 −1 Original line number Diff line number Diff line Loading @@ -30,3 +30,19 @@ TEST(Mutex, compile) { i = 0; modifyLockedVariable(); } TEST(Mutex, tryLock) { if (mLock.tryLock() != 0) { return; } mLock.unlock(); } #if defined(__ANDROID__) TEST(Mutex, timedLock) { if (mLock.timedLock(1) != 0) { return; } mLock.unlock(); } #endif libutils/include/utils/Mutex.h +2 −2 Original line number Diff line number Diff line Loading @@ -108,7 +108,7 @@ class CAPABILITY("mutex") Mutex { void unlock() RELEASE(); // lock if possible; returns 0 on success, error otherwise status_t tryLock() TRY_ACQUIRE(true); status_t tryLock() TRY_ACQUIRE(0); #if defined(__ANDROID__) // Lock the mutex, but don't wait longer than timeoutNs (relative time). Loading @@ -122,7 +122,7 @@ class CAPABILITY("mutex") Mutex { // which is subject to NTP adjustments, and includes time during suspend, // so a timeout may occur even though no processes could run. // Not holding a partial wakelock may lead to a system suspend. status_t timedLock(nsecs_t timeoutNs) TRY_ACQUIRE(true); status_t timedLock(nsecs_t timeoutNs) TRY_ACQUIRE(0); #endif // Manages the mutex automatically. It'll be locked when Autolock is Loading Loading
libutils/Mutex_test.cpp +17 −1 Original line number Diff line number Diff line Loading @@ -30,3 +30,19 @@ TEST(Mutex, compile) { i = 0; modifyLockedVariable(); } TEST(Mutex, tryLock) { if (mLock.tryLock() != 0) { return; } mLock.unlock(); } #if defined(__ANDROID__) TEST(Mutex, timedLock) { if (mLock.timedLock(1) != 0) { return; } mLock.unlock(); } #endif
libutils/include/utils/Mutex.h +2 −2 Original line number Diff line number Diff line Loading @@ -108,7 +108,7 @@ class CAPABILITY("mutex") Mutex { void unlock() RELEASE(); // lock if possible; returns 0 on success, error otherwise status_t tryLock() TRY_ACQUIRE(true); status_t tryLock() TRY_ACQUIRE(0); #if defined(__ANDROID__) // Lock the mutex, but don't wait longer than timeoutNs (relative time). Loading @@ -122,7 +122,7 @@ class CAPABILITY("mutex") Mutex { // which is subject to NTP adjustments, and includes time during suspend, // so a timeout may occur even though no processes could run. // Not holding a partial wakelock may lead to a system suspend. status_t timedLock(nsecs_t timeoutNs) TRY_ACQUIRE(true); status_t timedLock(nsecs_t timeoutNs) TRY_ACQUIRE(0); #endif // Manages the mutex automatically. It'll be locked when Autolock is Loading