mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-23 07:52:25 +00:00
Tweak concurrency limits
Create capacity for 2x max, but lie about it
This commit is contained in:
parent
510d0d4753
commit
6d0ca7d11f
2 changed files with 6 additions and 2 deletions
|
@ -39,7 +39,7 @@ namespace tools
|
||||||
threadpool::threadpool() : running(true), active(0) {
|
threadpool::threadpool() : running(true), active(0) {
|
||||||
boost::thread::attributes attrs;
|
boost::thread::attributes attrs;
|
||||||
attrs.set_stack_size(THREAD_STACK_SIZE);
|
attrs.set_stack_size(THREAD_STACK_SIZE);
|
||||||
max = tools::get_max_concurrency();
|
max = tools::get_max_concurrency() * 2;
|
||||||
size_t i = max;
|
size_t i = max;
|
||||||
while(i--) {
|
while(i--) {
|
||||||
threads.push_back(boost::thread(attrs, boost::bind(&threadpool::run, this)));
|
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() {
|
void threadpool::waiter::wait() {
|
||||||
boost::unique_lock<boost::mutex> lock(mt);
|
boost::unique_lock<boost::mutex> lock(mt);
|
||||||
while(num) cv.wait(lock);
|
while(num) cv.wait(lock);
|
||||||
|
|
|
@ -65,7 +65,7 @@ public:
|
||||||
// task to finish.
|
// task to finish.
|
||||||
void submit(waiter *waiter, std::function<void()> f);
|
void submit(waiter *waiter, std::function<void()> f);
|
||||||
|
|
||||||
int get_max_concurrency() { return max; }
|
int get_max_concurrency();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
threadpool();
|
threadpool();
|
||||||
|
|
Loading…
Reference in a new issue