common/threadsafe_queue: Provide Wait() method.

It shall block until there is something to consume in the queue.

And use it for the GPU emulation instead of the spin loop.
This is only in booting the emulator, however in BOTW this is the case for about 1 second.
This commit is contained in:
Markus Wick
2021-04-06 20:30:22 +02:00
parent 3173a53db9
commit 4aec060f6d
2 changed files with 10 additions and 3 deletions

View File

@ -83,11 +83,15 @@ public:
return true;
}
T PopWait() {
void Wait() {
if (Empty()) {
std::unique_lock lock{cv_mutex};
cv.wait(lock, [this]() { return !Empty(); });
}
}
T PopWait() {
Wait();
T t;
Pop(t);
return t;
@ -156,6 +160,10 @@ public:
return spsc_queue.Pop(t);
}
void Wait() {
spsc_queue.Wait();
}
T PopWait() {
return spsc_queue.PopWait();
}