summaryrefslogtreecommitdiffstats
path: root/src/common/thread_worker.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-03-23 01:00:48 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2021-07-09 00:00:39 +0200
commitf28dd32275c1feba4854abad30ff5e21a7b39440 (patch)
tree8cb51136e8bcd03418ce71878cc0e7478606ff25 /src/common/thread_worker.cpp
parentMerge pull request #6539 from lat9nq/default-setting (diff)
downloadyuzu-f28dd32275c1feba4854abad30ff5e21a7b39440.tar
yuzu-f28dd32275c1feba4854abad30ff5e21a7b39440.tar.gz
yuzu-f28dd32275c1feba4854abad30ff5e21a7b39440.tar.bz2
yuzu-f28dd32275c1feba4854abad30ff5e21a7b39440.tar.lz
yuzu-f28dd32275c1feba4854abad30ff5e21a7b39440.tar.xz
yuzu-f28dd32275c1feba4854abad30ff5e21a7b39440.tar.zst
yuzu-f28dd32275c1feba4854abad30ff5e21a7b39440.zip
Diffstat (limited to 'src/common/thread_worker.cpp')
-rw-r--r--src/common/thread_worker.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/thread_worker.cpp b/src/common/thread_worker.cpp
index 8f9bf447a..745918c7e 100644
--- a/src/common/thread_worker.cpp
+++ b/src/common/thread_worker.cpp
@@ -29,6 +29,10 @@ ThreadWorker::ThreadWorker(std::size_t num_workers, const std::string& name) {
}
task = std::move(requests.front());
requests.pop();
+
+ if (requests.empty()) {
+ wait_condition.notify_one();
+ }
}
task();
@@ -55,4 +59,9 @@ void ThreadWorker::QueueWork(std::function<void()>&& work) {
condition.notify_one();
}
+void ThreadWorker::WaitForRequests() {
+ std::unique_lock lock{queue_mutex};
+ wait_condition.wait(lock, [this] { return stop || requests.empty(); });
+}
+
} // namespace Common