Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cce9c65f authored by Mikhail Naganov's avatar Mikhail Naganov Committed by android-build-merger
Browse files

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

am: 8105c311

Change-Id: Idb3b730d5ec3a7c0101f7b5e782c587a252908d0
parents 0b2474d8 8105c311
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -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
+2 −2
Original line number Diff line number Diff line
@@ -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).
@@ -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