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

Commit 3715b63a authored by Lajos Molnar's avatar Lajos Molnar Committed by Android (Google) Code Review
Browse files

Merge "stagefright: fix prvalue handling in Mutexed" into nyc-dev

parents 8905fc7a 9f8bb269
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -103,6 +103,10 @@ public:
    class Locked {
    public:
        inline Locked(Mutexed<T> &mParent);
        inline Locked(Locked &&from) :
            mLock(from.mLock),
            mTreasure(from.mTreasure),
            mLocked(from.mLocked) {}
        inline ~Locked();

        // dereference the protected structure. This returns nullptr if the
@@ -148,9 +152,9 @@ public:
    // Lock the mutex, and create an accessor-guard (a Locked object) to access the underlying
    // structure. This returns an object that dereferences to the wrapped structure when the mutex
    // is locked by it, or otherwise to "null".
    inline Locked&& lock() {
        // use rvalue as Locked has no copy constructor
        return std::move(Locked(*this));
    // This is just a shorthand for Locked() constructor to avoid specifying the template type.
    inline Locked lock() {
        return Locked(*this);
    }

private:
@@ -169,7 +173,6 @@ inline Mutexed<T>::Locked::Locked(Mutexed<T> &mParent)
      mTreasure(mParent.mTreasure),
      mLocked(true) {
    mLock.lock();

}

template<typename T>