usql update
This commit is contained in:
@@ -30,11 +30,10 @@ namespace usql {
|
||||
char *line_str = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
// TODO handle it by settings
|
||||
const std::size_t hw_concurrency = std::max(0, (int)(std::thread::hardware_concurrency() - 2));
|
||||
const std::size_t hw_concurrency = getConcurrency();
|
||||
const bool use_threadpool = hw_concurrency > 1;
|
||||
|
||||
thread_pool tp{hw_concurrency};
|
||||
ThreadPool tp{hw_concurrency};
|
||||
std::mutex row_cnt_mutex;
|
||||
|
||||
try {
|
||||
@@ -140,4 +139,22 @@ namespace usql {
|
||||
return row_cnt;
|
||||
}
|
||||
|
||||
size_t CsvReader::getConcurrency() {
|
||||
auto value = Settings::get_setting("MAX_PARALLELISM");
|
||||
if (value == "1" || value == "0")
|
||||
return 0;
|
||||
else if (value == "AUTO")
|
||||
return std::thread::hardware_concurrency();
|
||||
else {
|
||||
char *end;
|
||||
long i = strtol( value.c_str(), &end, 10 );
|
||||
if ( *end == '\0' ) { // Success
|
||||
if (i >= 0) return i;
|
||||
else return std::max(std::thread::hardware_concurrency() + i, 0l);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user