diff --git a/app/src/main/cpp/skyline/common/circular_queue.h b/app/src/main/cpp/skyline/common/circular_queue.h index cd209d50..50ef3995 100644 --- a/app/src/main/cpp/skyline/common/circular_queue.h +++ b/app/src/main/cpp/skyline/common/circular_queue.h @@ -76,6 +76,21 @@ namespace skyline { } } + Type Pop() { + std::unique_lock lock(productionMutex); + produceCondition.wait(lock, [this]() { return start != end; }); + + auto next{start + 1}; + next = (next == reinterpret_cast(vector.end().base())) ? reinterpret_cast(vector.begin().base()) : next; + Type item{*next}; + start = next; + + if (start == end) + consumeCondition.notify_one(); + + return item; + } + void Push(const Type &item) { std::unique_lock lock(productionMutex); auto next{end + 1};