diff options
author | luigi1111 <luigi1111w@gmail.com> | 2018-06-17 22:04:39 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2018-06-17 22:04:39 -0500 |
commit | cfd66dae4b37b0cecad1021b37ca7ef4c5c82957 (patch) | |
tree | 645df00bdefe19b1fbf8e0593b5f357084101eca /src/common/threadpool.cpp | |
parent | Merge pull request #3804 (diff) | |
parent | unit_tests: add threadpool unit test (diff) | |
download | monero-cfd66dae4b37b0cecad1021b37ca7ef4c5c82957.tar.xz |
Merge pull request #3691
db55263 threadpool: allow constructing an object, and misc tweaks (moneromooo-monero)
ce173cb core: remove threadpool dependency from header (moneromooo-monero)
3147468 unit_tests: add threadpool unit test (moneromooo-monero)
Diffstat (limited to 'src/common/threadpool.cpp')
-rw-r--r-- | src/common/threadpool.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/common/threadpool.cpp b/src/common/threadpool.cpp index 51e071577..fb238dca7 100644 --- a/src/common/threadpool.cpp +++ b/src/common/threadpool.cpp @@ -39,11 +39,11 @@ static __thread int depth = 0; namespace tools { -threadpool::threadpool() : running(true), active(0) { +threadpool::threadpool(unsigned int max_threads) : running(true), active(0) { boost::thread::attributes attrs; attrs.set_stack_size(THREAD_STACK_SIZE); - max = tools::get_max_concurrency(); - size_t i = max; + max = max_threads ? max_threads : tools::get_max_concurrency(); + unsigned int i = max; while(i--) { threads.push_back(boost::thread(attrs, boost::bind(&threadpool::run, this))); } @@ -78,7 +78,7 @@ void threadpool::submit(waiter *obj, std::function<void()> f) { } } -int threadpool::get_max_concurrency() { +unsigned int threadpool::get_max_concurrency() const { return max; } |