diff options
| author | 2021-04-06 06:02:44 +0200 | |
|---|---|---|
| committer | 2021-07-08 19:03:26 -0300 | |
| commit | c147e9a90e92ceec17d778d3c6e5cf6f028109b3 (patch) | |
| tree | 9b584776a83fe55eecb43941d8f070db4f9efc71 /src/common/thread_worker.cpp | |
| parent | common/thread_worker: Fix data race (diff) | |
| download | yuzu-c147e9a90e92ceec17d778d3c6e5cf6f028109b3.tar.gz yuzu-c147e9a90e92ceec17d778d3c6e5cf6f028109b3.tar.xz yuzu-c147e9a90e92ceec17d778d3c6e5cf6f028109b3.zip | |
common/thread_worker: Simplify logic
Diffstat (limited to 'src/common/thread_worker.cpp')
| -rw-r--r-- | src/common/thread_worker.cpp | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/src/common/thread_worker.cpp b/src/common/thread_worker.cpp index fd130dfb4..32be49b15 100644 --- a/src/common/thread_worker.cpp +++ b/src/common/thread_worker.cpp | |||
| @@ -12,13 +12,6 @@ ThreadWorker::ThreadWorker(std::size_t num_workers, const std::string& name) { | |||
| 12 | const auto lambda = [this, thread_name{std::string{name}}] { | 12 | const auto lambda = [this, thread_name{std::string{name}}] { |
| 13 | Common::SetCurrentThreadName(thread_name.c_str()); | 13 | Common::SetCurrentThreadName(thread_name.c_str()); |
| 14 | 14 | ||
| 15 | // TODO(Blinkhawk): Change the design, this is very prone to data races | ||
| 16 | // Wait for first request | ||
| 17 | { | ||
| 18 | std::unique_lock lock{queue_mutex}; | ||
| 19 | condition.wait(lock, [this] { return stop || !requests.empty(); }); | ||
| 20 | } | ||
| 21 | |||
| 22 | while (!stop) { | 15 | while (!stop) { |
| 23 | UniqueFunction<void> task; | 16 | UniqueFunction<void> task; |
| 24 | { | 17 | { |
| @@ -27,7 +20,7 @@ ThreadWorker::ThreadWorker(std::size_t num_workers, const std::string& name) { | |||
| 27 | wait_condition.notify_all(); | 20 | wait_condition.notify_all(); |
| 28 | } | 21 | } |
| 29 | condition.wait(lock, [this] { return stop || !requests.empty(); }); | 22 | condition.wait(lock, [this] { return stop || !requests.empty(); }); |
| 30 | if (stop || requests.empty()) { | 23 | if (stop) { |
| 31 | break; | 24 | break; |
| 32 | } | 25 | } |
| 33 | task = std::move(requests.front()); | 26 | task = std::move(requests.front()); |