Skip to content

Commit

Permalink
Merge pull request #855 from redboltz/auto_decide_threads
Browse files Browse the repository at this point in the history
Added num of threads auto decide mode (set to 0).
  • Loading branch information
redboltz authored Sep 7, 2021
2 parents 70e45c2 + 8485369 commit f318a33
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit f318a33

Please sign in to comment.