Skip to content

Commit e85fb39

Browse files
authored
Merge pull request #871 from redboltz/add_auto_threads_per_ioc
Add auto threads per ioc
2 parents 66f384d + bfcc7f3 commit e85fb39

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## 12.0.0
2-
* Added io_context and threads setting options for example broker (#866)
2+
* Improved exampless (#870)
3+
* Fixed example broker's invalid sync connack call (#869)
4+
* Added no CONNACK sending mode to the example broker (#869)
5+
* Added posting code to acceptors (#867)
6+
* Added io_context and threads setting options for example broker (#866, #871)
37
* Fixed moved from object access (#865)
48
* <<<< breaking change >>>> Removed ioc_con() and ioc_accept() (#866)
59
* <<<< breaking change >>>> Unified automatic async/sync choosing flag. (#857, #862)
@@ -14,7 +18,7 @@
1418
* Added multi thread support for example broker (#842, #855, #866)
1519
* Replaced example broker's API call from sync to async (#842)
1620
* Replaced use_certificate_file() with use_certificate_chain_file() to support both server cert and server - intermediate CA cert (#841)
17-
* <<<< breaking change >>>> Added async_force_disconnect(). force_disconnect() is removed from async_client (#840)
21+
* <<<< breaking change >>>> Added async_force_disconnect(). force_disconnect() is removed from async_client (#840, #868)
1822
* Added will delay interval support (#839)
1923
* Fixed async_handler_t calling timing (#836)
2024
* Added BOOST_ASIO_NO_TS_EXECUTORS support (#830)

example/broker.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <boost/program_options.hpp>
1111

1212
#include <fstream>
13+
#include <algorithm>
1314

1415
namespace as = boost::asio;
1516

@@ -349,8 +350,8 @@ void run_broker(boost::program_options::variables_map const& vm) {
349350
return 1;
350351
} ();
351352
if (threads_per_ioc == 0) {
352-
MQTT_LOG("mqtt_broker", error) << "threads per ioc must be greater than 0";
353-
return;
353+
threads_per_ioc = std::max(std::size_t(std::thread::hardware_concurrency()), std::size_t(4));
354+
MQTT_LOG("mqtt_broker", info) << "threads_per_ioc set to auto decide (0). Automatically set to " << threads_per_ioc;
354355
}
355356

356357
MQTT_LOG("mqtt_broker", info)

0 commit comments

Comments
 (0)