mirror of
https://github.com/monero-project/monero.git
synced 2025-06-22 01:24:10 -04:00
add a --max-concurrency flag
It sets the max number of threads to use for a parallel job. This is different that the number of total threads, since monero binaries typically start a lot of them.
This commit is contained in:
parent
bdb93cbf3d
commit
513a658c87
8 changed files with 47 additions and 7 deletions
|
@ -422,4 +422,27 @@ std::string get_nix_version_display_string()
|
|||
umask(mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
boost::mutex max_concurrency_lock;
|
||||
unsigned max_concurrency = boost::thread::hardware_concurrency();
|
||||
}
|
||||
|
||||
void set_max_concurrency(unsigned n)
|
||||
{
|
||||
if (n < 1)
|
||||
n = boost::thread::hardware_concurrency();
|
||||
unsigned hwc = boost::thread::hardware_concurrency();
|
||||
if (n > hwc)
|
||||
n = hwc;
|
||||
boost::lock_guard<boost::mutex> lock(max_concurrency_lock);
|
||||
max_concurrency = n;
|
||||
}
|
||||
|
||||
unsigned get_max_concurrency()
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(max_concurrency_lock);
|
||||
return max_concurrency;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,4 +160,7 @@ namespace tools
|
|||
};
|
||||
|
||||
void set_strict_default_file_permissions(bool strict);
|
||||
|
||||
void set_max_concurrency(unsigned n);
|
||||
unsigned get_max_concurrency();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue