diff options
author | Howard Chu <hyc@symas.com> | 2017-09-15 00:28:48 +0100 |
---|---|---|
committer | Howard Chu <hyc@symas.com> | 2017-09-15 00:28:48 +0100 |
commit | 6d0ca7d11f18d1d842ec1ac639da4309ae41a83f (patch) | |
tree | 756c8c666df79b0f15dba3f0bac15505453966e9 /src/common | |
parent | Use a threadpool (diff) | |
download | monero-6d0ca7d11f18d1d842ec1ac639da4309ae41a83f.tar.xz |
Tweak concurrency limits
Create capacity for 2x max, but lie about it
Diffstat (limited to '')
-rw-r--r-- | src/common/threadpool.cpp | 6 | ||||
-rw-r--r-- | src/common/threadpool.h | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/common/threadpool.cpp b/src/common/threadpool.cpp index f7f9bbbaf..41d0c25e0 100644 --- a/src/common/threadpool.cpp +++ b/src/common/threadpool.cpp @@ -39,7 +39,7 @@ namespace tools threadpool::threadpool() : running(true), active(0) { boost::thread::attributes attrs; attrs.set_stack_size(THREAD_STACK_SIZE); - max = tools::get_max_concurrency(); + max = tools::get_max_concurrency() * 2; size_t i = max; while(i--) { threads.push_back(boost::thread(attrs, boost::bind(&threadpool::run, this))); @@ -73,6 +73,10 @@ void threadpool::submit(waiter *obj, std::function<void()> f) { } } +int threadpool::get_max_concurrency() { + return max / 2; +} + void threadpool::waiter::wait() { boost::unique_lock<boost::mutex> lock(mt); while(num) cv.wait(lock); diff --git a/src/common/threadpool.h b/src/common/threadpool.h index 9455e9f66..1d56d7605 100644 --- a/src/common/threadpool.h +++ b/src/common/threadpool.h @@ -65,7 +65,7 @@ public: // task to finish. void submit(waiter *waiter, std::function<void()> f); - int get_max_concurrency() { return max; } + int get_max_concurrency(); private: threadpool(); |