summaryrefslogtreecommitdiffstats
path: root/libs/gui/include
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2019-04-02 02:27:44 +0200
committerJorim Jaggi <jjaggi@google.com>2019-04-02 22:40:12 +0200
commit6ae550323264bacc45da2d8fca90534d02815308 (patch)
treea5d454e64bb476853955bb98f90cf1f6c39e1f3c /libs/gui/include
parent8ef2683431551314d9bf82f80672996cbb4142be (diff)
downloadandroid_frameworks_native-6ae550323264bacc45da2d8fca90534d02815308.tar.gz
android_frameworks_native-6ae550323264bacc45da2d8fca90534d02815308.tar.bz2
android_frameworks_native-6ae550323264bacc45da2d8fca90534d02815308.zip
Convert Mutex to std::mutex in BufferQueueCore/Producer/Consumer
Bug: 111517695 Change-Id: I1226ed7396d0d768a26f4145af5fe48e2c70e8d2
Diffstat (limited to 'libs/gui/include')
-rw-r--r--libs/gui/include/gui/BufferQueueCore.h12
-rw-r--r--libs/gui/include/gui/BufferQueueProducer.h7
2 files changed, 10 insertions, 9 deletions
diff --git a/libs/gui/include/gui/BufferQueueCore.h b/libs/gui/include/gui/BufferQueueCore.h
index b377a412b..0e8028380 100644
--- a/libs/gui/include/gui/BufferQueueCore.h
+++ b/libs/gui/include/gui/BufferQueueCore.h
@@ -22,8 +22,6 @@
#include <gui/BufferSlot.h>
#include <gui/OccupancyTracker.h>
-#include <utils/Condition.h>
-#include <utils/Mutex.h>
#include <utils/NativeHandle.h>
#include <utils/RefBase.h>
#include <utils/String8.h>
@@ -33,6 +31,8 @@
#include <list>
#include <set>
+#include <mutex>
+#include <condition_variable>
#define BQ_LOGV(x, ...) ALOGV("[%s] " x, mConsumerName.string(), ##__VA_ARGS__)
#define BQ_LOGD(x, ...) ALOGD("[%s] " x, mConsumerName.string(), ##__VA_ARGS__)
@@ -134,7 +134,7 @@ private:
bool adjustAvailableSlotsLocked(int delta);
// waitWhileAllocatingLocked blocks until mIsAllocating is false.
- void waitWhileAllocatingLocked() const;
+ void waitWhileAllocatingLocked(std::unique_lock<std::mutex>& lock) const;
#if DEBUG_ONLY_CODE
// validateConsistencyLocked ensures that the free lists are in sync with
@@ -145,7 +145,7 @@ private:
// mMutex is the mutex used to prevent concurrent access to the member
// variables of BufferQueueCore objects. It must be locked whenever any
// member variable is accessed.
- mutable Mutex mMutex;
+ mutable std::mutex mMutex;
// mIsAbandoned indicates that the BufferQueue will no longer be used to
// consume image buffers pushed to it using the IGraphicBufferProducer
@@ -219,7 +219,7 @@ private:
// mDequeueCondition is a condition variable used for dequeueBuffer in
// synchronous mode.
- mutable Condition mDequeueCondition;
+ mutable std::condition_variable mDequeueCondition;
// mDequeueBufferCannotBlock indicates whether dequeueBuffer is allowed to
// block. This flag is set during connect when both the producer and
@@ -282,7 +282,7 @@ private:
// mIsAllocatingCondition is a condition variable used by producers to wait until mIsAllocating
// becomes false.
- mutable Condition mIsAllocatingCondition;
+ mutable std::condition_variable mIsAllocatingCondition;
// mAllowAllocation determines whether dequeueBuffer is allowed to allocate
// new buffers
diff --git a/libs/gui/include/gui/BufferQueueProducer.h b/libs/gui/include/gui/BufferQueueProducer.h
index 73bc5dd31..b6e98862f 100644
--- a/libs/gui/include/gui/BufferQueueProducer.h
+++ b/libs/gui/include/gui/BufferQueueProducer.h
@@ -211,7 +211,8 @@ private:
Dequeue,
Attach,
};
- status_t waitForFreeSlotThenRelock(FreeSlotCaller caller, int* found) const;
+ status_t waitForFreeSlotThenRelock(FreeSlotCaller caller, std::unique_lock<std::mutex>& lock,
+ int* found) const;
sp<BufferQueueCore> mCore;
@@ -243,10 +244,10 @@ private:
// (mCore->mMutex) is held, a ticket is retained by the producer. After
// dropping the BufferQueue lock, the producer must wait on the condition
// variable until the current callback ticket matches its retained ticket.
- Mutex mCallbackMutex;
+ std::mutex mCallbackMutex;
int mNextCallbackTicket; // Protected by mCore->mMutex
int mCurrentCallbackTicket; // Protected by mCallbackMutex
- Condition mCallbackCondition;
+ std::condition_variable mCallbackCondition;
// Sets how long dequeueBuffer or attachBuffer will block if a buffer or
// slot is not yet available.