diff options
author | Ilya Kitaev <mbg033@gmail.com> | 2016-05-12 15:14:30 +0300 |
---|---|---|
committer | Ilya Kitaev <mbg033@gmail.com> | 2016-05-12 15:14:30 +0300 |
commit | 2d799097ca8467f27c684ba36152ff4e83c6ad28 (patch) | |
tree | 023ca29ac16e5a9198920eaeb1e9dea59544e9b3 /src/common/util.cpp | |
parent | started WalletListener (diff) | |
parent | Merge pull request #826 (diff) | |
download | monero-2d799097ca8467f27c684ba36152ff4e83c6ad28.tar.xz |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/common/util.cpp')
-rw-r--r-- | src/common/util.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/common/util.cpp b/src/common/util.cpp index 2337f5766..a53a9be52 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -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; + } } |