Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added num of threads auto decide mode (set to 0). #855

Merged
merged 1 commit into from
Sep 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions example/broker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ void run_broker(boost::program_options::variables_map const& vm)
return 1;
} ();
if (threads == 0) {
MQTT_LOG("mqtt_broker", error) << "threads should be greater than 0";
return;
threads = std::thread::hardware_concurrency();
MQTT_LOG("mqtt_broker", info) << "threads set to auto decide (0). Automatically set to " << threads;
}
std::vector<std::thread> ts;
ts.reserve(threads);
Expand All @@ -165,7 +165,7 @@ int main(int argc, char **argv) {
general_desc.add_options()
("help", "produce help message")
("cfg", boost::program_options::value<std::string>()->default_value("broker.conf"), "Load configuration file")
("threads", boost::program_options::value<std::size_t>()->default_value(1), "Number of worker threads")
("threads", boost::program_options::value<std::size_t>()->default_value(1), "Number of worker threads. If set 0 then automatically decided by hardware_concurrency().")
#if defined(MQTT_USE_LOG)
("verbose", boost::program_options::value<unsigned int>()->default_value(1), "set verbose level, possible values:\n 0 - Fatal\n 1 - Error\n 2 - Warning\n 3 - Info\n 4 - Debug\n 5 - Trace")
#endif // defined(MQTT_USE_LOG)
Expand Down