Add workqueue system

This commit is contained in:
pixl
2020-07-10 03:16:51 -04:00
parent 02d361b541
commit 1f3fa53721
15 changed files with 529 additions and 15 deletions
+22 -1
View File
@@ -50,12 +50,28 @@ Configuration::Configuration(const std::string& config_file)
return;
}
_worker_threads = LOGID_DEFAULT_WORKER_COUNT;
try {
auto& worker_count = root["workers"];
if(worker_count.getType() == Setting::TypeInt) {
_worker_threads = worker_count;
if(_worker_threads < 0)
logPrintf(WARN, "Line %d: workers cannot be negative.",
worker_count.getSourceLine());
} else {
logPrintf(WARN, "Line %d: workers must be an integer.",
worker_count.getSourceLine());
}
} catch(const SettingNotFoundException& e) {
// Ignore
}
_io_timeout = LOGID_DEFAULT_RAWDEVICE_TIMEOUT;
try {
auto& timeout = root["io_timeout"];
if(timeout.isNumber()) {
auto t = timeout.getType();
if(timeout.getType() == libconfig::Setting::TypeFloat)
if(timeout.getType() == Setting::TypeFloat)
_io_timeout = duration_cast<milliseconds>(
duration<double, std::milli>(timeout));
else
@@ -109,6 +125,11 @@ const char * Configuration::DeviceNotFound::what() const noexcept
return _name.c_str();
}
int Configuration::workerCount() const
{
return _worker_threads;
}
std::chrono::milliseconds Configuration::ioTimeout() const
{
return _io_timeout;