diff options
Diffstat (limited to 'thread_pool.cc')
-rw-r--r-- | thread_pool.cc | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/thread_pool.cc b/thread_pool.cc index c504ef5..ba7ee00 100644 --- a/thread_pool.cc +++ b/thread_pool.cc @@ -17,7 +17,6 @@ #include <stack> #include <vector> -#include "affinity.h" #include "condvar.h" #include "mutex.h" #include "thread.h" @@ -26,7 +25,6 @@ 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(); })); @@ -37,14 +35,14 @@ class ThreadPoolImpl : public ThreadPool { } virtual void Submit(function<void(void)> task) override { - UniqueLock<Mutex> lock(mu_); + unique_lock<mutex> lock(mu_); tasks_.push(task); cond_.notify_one(); } virtual void Wait() override { { - UniqueLock<Mutex> lock(mu_); + unique_lock<mutex> lock(mu_); is_waiting_ = true; cond_.notify_all(); } @@ -52,8 +50,6 @@ class ThreadPoolImpl : public ThreadPool { for (thread& th : threads_) { th.join(); } - - SetAffinityForSingleThread(); } private: @@ -61,7 +57,7 @@ class ThreadPoolImpl : public ThreadPool { while (true) { function<void(void)> task; { - UniqueLock<Mutex> lock(mu_); + unique_lock<mutex> lock(mu_); if (tasks_.empty()) { if (is_waiting_) return; @@ -79,7 +75,7 @@ class ThreadPoolImpl : public ThreadPool { } vector<thread> threads_; - Mutex mu_; + mutex mu_; condition_variable cond_; stack<function<void(void)>> tasks_; bool is_waiting_; |