mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-05 14:45:07 +01:00
Implement popping from CircularQueue
This commit is contained in:
parent
6d9dc9c6fb
commit
379b4f163d
@ -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<Type *>(vector.end().base())) ? reinterpret_cast<Type *>(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};
|
||||
|
Loading…
Reference in New Issue
Block a user