Merge commit '9ca04ddfc715e0f7d29d3f6b39269ad9bf174230'
This commit is contained in:
commit
a3f0f5b089
1 changed files with 6 additions and 2 deletions
|
@ -58,12 +58,16 @@ using asio::windows::stream_handle;
|
||||||
|
|
||||||
namespace thespian::executor {
|
namespace thespian::executor {
|
||||||
|
|
||||||
|
const char *MIN_THREAD_STR = getenv("MIN_THREAD"); // NOLINT
|
||||||
|
const auto MIN_THREAD =
|
||||||
|
static_cast<long>(atoi(MIN_THREAD_STR ? MIN_THREAD_STR : "4")); // NOLINT
|
||||||
|
|
||||||
const char *MAX_THREAD_STR = getenv("MAX_THREAD"); // NOLINT
|
const char *MAX_THREAD_STR = getenv("MAX_THREAD"); // NOLINT
|
||||||
const auto MAX_THREAD =
|
const auto MAX_THREAD =
|
||||||
static_cast<long>(atoi(MAX_THREAD_STR ? MAX_THREAD_STR : "64")); // NOLINT
|
static_cast<long>(atoi(MAX_THREAD_STR ? MAX_THREAD_STR : "64")); // NOLINT
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
const auto threads = min(sysconf(_SC_NPROCESSORS_ONLN), MAX_THREAD);
|
const auto threads = max(min(sysconf(_SC_NPROCESSORS_ONLN), MAX_THREAD), MIN_THREAD);
|
||||||
#else
|
#else
|
||||||
namespace {
|
namespace {
|
||||||
static auto get_num_processors() -> long {
|
static auto get_num_processors() -> long {
|
||||||
|
@ -72,7 +76,7 @@ static auto get_num_processors() -> long {
|
||||||
return si.dwNumberOfProcessors;
|
return si.dwNumberOfProcessors;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
const auto threads = min(get_num_processors(), MAX_THREAD);
|
const auto threads = max(min(get_num_processors(), MAX_THREAD), MIN_THREAD);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct context_impl {
|
struct context_impl {
|
||||||
|
|
Loading…
Add table
Reference in a new issue