src/common/FixedQueue.h


Log

Author Commit Date CI Message
Igor Nazarov 24a3d30d 2024-08-28T14:33:49 Possibly fix FixedQueue.ConcurrentPushPopWithResize flakiness Queue may be empty when `enqueueThreadFinished` become true. Bug: b/302739073 Change-Id: Idb636e3f87c1217520a9e68a69e749f5bcac4d0f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5823039 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Igor Nazarov <i.nazarov@samsung.com> Reviewed-by: Charlie Lao <cclao@google.com>
Charlie Lao 6f794eab 2023-10-05T11:23:30 Change angle::FixedQueue's storage from std::array to std::vector Right now angle::FixedQueue uses std::array as the storage. In the case when queue is full, the only choice is to wait for dequeue thread to run until there is more room to enqueue. This CL try to add extra flexibility. In this CL< it switches storage to std::vector so that we could reallocate to double the storage when it is full. The trick is that before doing that, you must ensure no one is accessing the queue other than check the size. In a lot of usage cases that is easy to do by just grabbing the necessary locks. Bug: b/302739073 Change-Id: Ibefe0fd0e3e89c17dd6ee2cac6adc3368122adb9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4915811 Reviewed-by: Hailin Zhang <hailinzhang@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Jose Dapena Paz 5384667f 2023-03-20T10:23:13 IWYU: missing include for std::atomic in FixedQueue.h Fix build error using libstdc++ due to missing include for usage of std::atomic in FixedQueue.h: ../../third_party/angle/src/common/FixedQueue.h:61:10: error: ‘atomic’ in namespace ‘std’ does not name a template type 61 | std::atomic<size_type> mSize; | ^~~~~~ Bug: chromium:957519 Change-Id: I099a4a8c463149d74cf82ec6eda5e4a872d6e812 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4352888 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 044612ec 2023-02-27T14:59:29 Vulkan: Remove iterator from FixedQueue class Previously there was code that still walking each element of FixedQueue, that was mostly removed in previous CLs. The only remaining usage is for assertion which the value is minimal. This CL removes the iterator from FixedQueue so that it behaves just like queue, thus avoiding potential risk of misuse. Bug: b/255411748 Change-Id: I4c0debf5b6c8b603e384c681f1a123c2ee06dcbb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4294695 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Igor Nazarov 8374bf5f 2023-02-13T20:35:32 Fix bug in FixedQueue::clear() and refactoring. - bug: "mSize" used to end the loop but also changed inside the loop by call to the "pop()" method. - refactoring: "mBackIndex" name is not correct, because variable references to the "index for next write", in other words - to the element past "back" (last written). Renamed to "mEndIndex" to match the "std" terminology. Bug: b/267348918 Test: angle_unittests --gtest_filter="FixedQueue.Clear" Change-Id: Ic65291a7ff2ff6f4eed223ca80fef187e42df3e5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4245420 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Igor Nazarov <i.nazarov@samsung.com>
Charlie Lao 11951f2f 2023-01-31T09:56:16 Vulkan: Add FixedQueue class for CommandProcessor::mTask This CL adds FixedQueue class. It uses std::array for the storage. It supports concurrent push and pop from two different threads. If producer want to push from two different threads, then proper mutex must be used to ensure the access is serialized. Similarly if consumers want to pop from two different threads, a mutex must be used to ensure serialized access. Caller must ensure queue is not empty before pop and not full before push. This CL switches CommandProcessor::mTasks to FixedQueue and moved mSubmissionMutex to protect the serialized submission (i.e, pop from queue). mWorkerMutex is still used to protect push operation. With this change, we now supports continued enqueue to mTask of CommandProcessor while other context is doing CommandProcessor::waitForResourceUseToBeSubmitted(). Bug: b/267348918 Change-Id: I6c5fe288436daa7e0f3bcbbcd16c5d2e5e27f2e9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4210653 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>