summaryrefslogtreecommitdiffstats
path: root/src/common/thread.h
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2022-12-06 22:13:42 +0100
committerLiam <byteslice@airmail.cc>2022-12-06 22:13:42 +0100
commit9704acb982eb3dfb4b2b6a090f5613d4ac57b196 (patch)
treeffc2dd5818b94e61e09eed5388cb821c90dc0896 /src/common/thread.h
parentMerge pull request #9393 from liamwhite/more-vulkan (diff)
downloadyuzu-9704acb982eb3dfb4b2b6a090f5613d4ac57b196.tar
yuzu-9704acb982eb3dfb4b2b6a090f5613d4ac57b196.tar.gz
yuzu-9704acb982eb3dfb4b2b6a090f5613d4ac57b196.tar.bz2
yuzu-9704acb982eb3dfb4b2b6a090f5613d4ac57b196.tar.lz
yuzu-9704acb982eb3dfb4b2b6a090f5613d4ac57b196.tar.xz
yuzu-9704acb982eb3dfb4b2b6a090f5613d4ac57b196.tar.zst
yuzu-9704acb982eb3dfb4b2b6a090f5613d4ac57b196.zip
Diffstat (limited to '')
-rw-r--r--src/common/thread.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/common/thread.h b/src/common/thread.h
index e17a7850f..8ae169b4e 100644
--- a/src/common/thread.h
+++ b/src/common/thread.h
@@ -11,6 +11,7 @@
#include <mutex>
#include <thread>
#include "common/common_types.h"
+#include "common/polyfill_thread.h"
namespace Common {
@@ -69,7 +70,7 @@ public:
explicit Barrier(std::size_t count_) : count(count_) {}
/// Blocks until all "count" threads have called Sync()
- void Sync() {
+ bool Sync(std::stop_token token = {}) {
std::unique_lock lk{mutex};
const std::size_t current_generation = generation;
@@ -77,14 +78,16 @@ public:
generation++;
waiting = 0;
condvar.notify_all();
+ return true;
} else {
- condvar.wait(lk,
- [this, current_generation] { return current_generation != generation; });
+ CondvarWait(condvar, lk, token,
+ [this, current_generation] { return current_generation != generation; });
+ return !token.stop_requested();
}
}
private:
- std::condition_variable condvar;
+ std::condition_variable_any condvar;
std::mutex mutex;
std::size_t count;
std::size_t waiting = 0;