aboutsummaryrefslogtreecommitdiff
path: root/thread_pool.cc
diff options
context:
space:
mode:
Diffstat (limited to 'thread_pool.cc')
-rw-r--r--thread_pool.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/thread_pool.cc b/thread_pool.cc
index ba7ee00..0a12bfa 100644
--- a/thread_pool.cc
+++ b/thread_pool.cc
@@ -14,17 +14,19 @@
#include "thread_pool.h"
+#include <condition_variable>
+#include <mutex>
#include <stack>
+#include <thread>
#include <vector>
-#include "condvar.h"
-#include "mutex.h"
-#include "thread.h"
+#include "affinity.h"
class ThreadPoolImpl : public ThreadPool {
public:
explicit ThreadPoolImpl(int num_threads)
: is_waiting_(false) {
+ SetAffinityForMultiThread();
threads_.reserve(num_threads);
for (int i = 0; i < num_threads; i++) {
threads_.push_back(thread([this]() { Loop(); }));
@@ -50,6 +52,8 @@ class ThreadPoolImpl : public ThreadPool {
for (thread& th : threads_) {
th.join();
}
+
+ SetAffinityForSingleThread();
}
private: