mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-15 13:10:05 +00:00
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:
parent
3173a53db9
commit
4aec060f6d
@ -83,11 +83,15 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
T PopWait() {
|
void Wait() {
|
||||||
if (Empty()) {
|
if (Empty()) {
|
||||||
std::unique_lock lock{cv_mutex};
|
std::unique_lock lock{cv_mutex};
|
||||||
cv.wait(lock, [this]() { return !Empty(); });
|
cv.wait(lock, [this]() { return !Empty(); });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
T PopWait() {
|
||||||
|
Wait();
|
||||||
T t;
|
T t;
|
||||||
Pop(t);
|
Pop(t);
|
||||||
return t;
|
return t;
|
||||||
@ -156,6 +160,10 @@ public:
|
|||||||
return spsc_queue.Pop(t);
|
return spsc_queue.Pop(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Wait() {
|
||||||
|
spsc_queue.Wait();
|
||||||
|
}
|
||||||
|
|
||||||
T PopWait() {
|
T PopWait() {
|
||||||
return spsc_queue.PopWait();
|
return spsc_queue.PopWait();
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,7 @@ static void RunThread(Core::System& system, VideoCore::RendererBase& renderer,
|
|||||||
system.RegisterHostThread();
|
system.RegisterHostThread();
|
||||||
|
|
||||||
// Wait for first GPU command before acquiring the window context
|
// Wait for first GPU command before acquiring the window context
|
||||||
while (state.queue.Empty())
|
state.queue.Wait();
|
||||||
;
|
|
||||||
|
|
||||||
// If emulation was stopped during disk shader loading, abort before trying to acquire context
|
// If emulation was stopped during disk shader loading, abort before trying to acquire context
|
||||||
if (!state.is_running) {
|
if (!state.is_running) {
|
||||||
|
Loading…
Reference in New Issue
Block a user