summaryrefslogtreecommitdiff
path: root/src/common/thread_worker.h
diff options
context:
space:
mode:
authorGravatar bunnei2020-12-30 22:06:05 -0800
committerGravatar GitHub2020-12-30 22:06:05 -0800
commit25d607f5f63929369fb74f386a920b69bb24f442 (patch)
tree9ee5a023f033d99561a0358c5c71aeecc92c9d64 /src/common/thread_worker.h
parentMerge pull request #5263 from lioncash/uninit (diff)
parenthle: kernel: service_thread: Make thread naming more consistent. (diff)
downloadyuzu-25d607f5f63929369fb74f386a920b69bb24f442.tar.gz
yuzu-25d607f5f63929369fb74f386a920b69bb24f442.tar.xz
yuzu-25d607f5f63929369fb74f386a920b69bb24f442.zip
Merge pull request #5208 from bunnei/service-threads
Service threads
Diffstat (limited to 'src/common/thread_worker.h')
-rw-r--r--src/common/thread_worker.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/common/thread_worker.h b/src/common/thread_worker.h
new file mode 100644
index 000000000..f1859971f
--- /dev/null
+++ b/src/common/thread_worker.h
@@ -0,0 +1,30 @@
1// Copyright 2020 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <atomic>
8#include <functional>
9#include <mutex>
10#include <string>
11#include <vector>
12#include <queue>
13
14namespace Common {
15
16class ThreadWorker final {
17public:
18 explicit ThreadWorker(std::size_t num_workers, const std::string& name);
19 ~ThreadWorker();
20 void QueueWork(std::function<void()>&& work);
21
22private:
23 std::vector<std::thread> threads;
24 std::queue<std::function<void()>> requests;
25 std::mutex queue_mutex;
26 std::condition_variable condition;
27 std::atomic_bool stop{};
28};
29
30} // namespace Common