diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/util.cpp | 32 | ||||
-rw-r--r-- | src/common/util.h | 5 |
2 files changed, 37 insertions, 0 deletions
diff --git a/src/common/util.cpp b/src/common/util.cpp index 6f75e5bad..a53a9be52 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -413,4 +413,36 @@ std::string get_nix_version_display_string() } return false; } + void set_strict_default_file_permissions(bool strict) + { +#if defined(__MINGW32__) || defined(__MINGW__) + // no clue about the odd one out +#else + mode_t mode = strict ? 077 : 0; + 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; + } } diff --git a/src/common/util.h b/src/common/util.h index 7554b1df7..4fcf66b8f 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -158,4 +158,9 @@ namespace tools /*! \brief where the installed handler is stored */ static std::function<void(int)> m_handler; }; + + void set_strict_default_file_permissions(bool strict); + + void set_max_concurrency(unsigned n); + unsigned get_max_concurrency(); } |