customizable number of threadpool threads
This commit is contained in:
parent
570973fdcc
commit
99e5e9fca0
2 changed files with 15 additions and 3 deletions
|
@ -94,6 +94,7 @@
|
||||||
#define RELOAD_MODEL_BORDER_NUM 10
|
#define RELOAD_MODEL_BORDER_NUM 10
|
||||||
#define COOKIE_URL_IDENTIFIER ":COOKIE:"
|
#define COOKIE_URL_IDENTIFIER ":COOKIE:"
|
||||||
#define DEFAULT_NOTIFICATION_VOLUME 50
|
#define DEFAULT_NOTIFICATION_VOLUME 50
|
||||||
|
#define MAX_THREADPOOL_THREADS 32
|
||||||
|
|
||||||
#define GOOGLE_SEARCH_URL "https://www.google.com/search?q=%1&ie=utf-8&oe=utf-8"
|
#define GOOGLE_SEARCH_URL "https://www.google.com/search?q=%1&ie=utf-8&oe=utf-8"
|
||||||
#define GOOGLE_SUGGEST_URL "http://suggestqueries.google.com/complete/search?output=toolbar&hl=en&q=%1"
|
#define GOOGLE_SUGGEST_URL "http://suggestqueries.google.com/complete/search?output=toolbar&hl=en&q=%1"
|
||||||
|
@ -139,6 +140,8 @@
|
||||||
#define CLI_QUIT_INSTANCE "q"
|
#define CLI_QUIT_INSTANCE "q"
|
||||||
#define CLI_IS_RUNNING "a"
|
#define CLI_IS_RUNNING "a"
|
||||||
|
|
||||||
|
#define CLI_THREADS "threads"
|
||||||
|
|
||||||
#define HTTP_HEADERS_ACCEPT "Accept"
|
#define HTTP_HEADERS_ACCEPT "Accept"
|
||||||
#define HTTP_HEADERS_CONTENT_TYPE "Content-Type"
|
#define HTTP_HEADERS_CONTENT_TYPE "Content-Type"
|
||||||
#define HTTP_HEADERS_CONTENT_LENGTH "Content-Length"
|
#define HTTP_HEADERS_CONTENT_LENGTH "Content-Length"
|
||||||
|
|
|
@ -946,9 +946,13 @@ void Application::setupCustomDataFolder(const QString& data_folder) {
|
||||||
|
|
||||||
void Application::setupGlobalThreadPool() {
|
void Application::setupGlobalThreadPool() {
|
||||||
auto ideal_th_count = QThread::idealThreadCount();
|
auto ideal_th_count = QThread::idealThreadCount();
|
||||||
|
int custom_threads = m_cmdParser.value(QSL(CLI_THREADS)).toInt();
|
||||||
|
|
||||||
if (ideal_th_count > 1) {
|
if (custom_threads > 0) {
|
||||||
QThreadPool::globalInstance()->setMaxThreadCount((std::min)(32, 2 * ideal_th_count));
|
QThreadPool::globalInstance()->setMaxThreadCount((std::min)(MAX_THREADPOOL_THREADS, custom_threads));
|
||||||
|
}
|
||||||
|
else if (ideal_th_count > 1) {
|
||||||
|
QThreadPool::globalInstance()->setMaxThreadCount((std::min)(MAX_THREADPOOL_THREADS, 2 * ideal_th_count));
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Do not expire threads so that their IDs are not reused.
|
// NOTE: Do not expire threads so that their IDs are not reused.
|
||||||
|
@ -1156,12 +1160,17 @@ void Application::fillCmdArgumentsParser(QCommandLineParser& parser) {
|
||||||
QSL("Use custom port for AdBlock server. It is highly recommended to use values higher than 1024."),
|
QSL("Use custom port for AdBlock server. It is highly recommended to use values higher than 1024."),
|
||||||
QSL("port"));
|
QSL("port"));
|
||||||
|
|
||||||
|
QCommandLineOption custom_threads(QSL(CLI_THREADS),
|
||||||
|
QSL("Specify number of threads. Note that number cannot be higher than %1.")
|
||||||
|
.arg(MAX_THREADPOOL_THREADS),
|
||||||
|
QSL("count"));
|
||||||
|
|
||||||
parser.addOptions({
|
parser.addOptions({
|
||||||
help, version, log_file, custom_data_folder, disable_singleinstance, disable_only_debug, disable_debug,
|
help, version, log_file, custom_data_folder, disable_singleinstance, disable_only_debug, disable_debug,
|
||||||
#if defined(USE_WEBENGINE)
|
#if defined(USE_WEBENGINE)
|
||||||
force_nowebengine,
|
force_nowebengine,
|
||||||
#endif
|
#endif
|
||||||
forced_style, adblock_port, custom_ua
|
forced_style, adblock_port, custom_ua, custom_threads
|
||||||
});
|
});
|
||||||
parser.addPositionalArgument(QSL("urls"),
|
parser.addPositionalArgument(QSL("urls"),
|
||||||
QSL("List of URL addresses pointing to individual online feeds which should be added."),
|
QSL("List of URL addresses pointing to individual online feeds which should be added."),
|
||||||
|
|
Loading…
Add table
Reference in a new issue