|
18 | 18 | #define TNT_FILAMENT_BACKEND_PRIVATE_COMMANDBUFFERQUEUE_H |
19 | 19 |
|
20 | 20 | #include "private/backend/CircularBuffer.h" |
21 | | - |
22 | 21 | #include <utils/Condition.h> |
23 | 22 | #include <utils/Mutex.h> |
| 23 | +#include <utils/compiler.h> |
24 | 24 |
|
25 | | -#include <vector> |
26 | | -#include <exception> |
27 | 25 | #include <atomic> |
| 26 | +#include <condition_variable> |
| 27 | +#include <exception> |
| 28 | +#include <mutex> |
| 29 | +#include <vector> |
28 | 30 |
|
29 | 31 | #include <stddef.h> |
30 | 32 | #include <stdint.h> |
@@ -54,7 +56,10 @@ class CommandBufferQueue { |
54 | 56 |
|
55 | 57 | size_t getCapacity() const noexcept { return mRequiredSize; } |
56 | 58 |
|
57 | | - size_t getHighWatermark() const noexcept { return mHighWatermark; } |
| 59 | + size_t getHighWatermark() const noexcept { |
| 60 | + std::lock_guard const lock(mLock); |
| 61 | + return mHighWatermark; |
| 62 | + } |
58 | 63 |
|
59 | 64 | // wait for commands to be available and returns an array containing these commands |
60 | 65 | std::vector<Range> waitForCommands() const; |
@@ -103,13 +108,13 @@ class CommandBufferQueue { |
103 | 108 |
|
104 | 109 | // space available in the circular buffer |
105 | 110 |
|
106 | | - mutable utils::Mutex mLock; |
107 | | - mutable utils::Condition mCondition; |
108 | | - mutable std::vector<Range> mCommandBuffersToExecute; |
109 | | - size_t mFreeSpace = 0; |
110 | | - size_t mHighWatermark = 0; |
111 | | - uint32_t mExitRequested = 0; |
112 | | - bool mPaused = false; |
| 111 | + mutable std::mutex mLock; |
| 112 | + mutable std::condition_variable mCondition; |
| 113 | + mutable std::vector<Range> mCommandBuffersToExecute UTILS_GUARDED_BY(mLock); |
| 114 | + size_t mFreeSpace UTILS_GUARDED_BY(mLock) = 0; |
| 115 | + size_t mHighWatermark UTILS_GUARDED_BY(mLock) = 0; |
| 116 | + uint32_t mExitRequested UTILS_GUARDED_BY(mLock) = 0; |
| 117 | + bool mPaused UTILS_GUARDED_BY(mLock) = false; |
113 | 118 |
|
114 | 119 | static constexpr uint32_t EXIT_REQUESTED = 0x31415926; |
115 | 120 |
|
|
0 commit comments