Skip to content

Commit e7b9f10

Browse files
authored
Merge pull request #872 from redboltz/fix_auto_threads_per_ioc
Fixed automatic threads_per_ioc logic.
2 parents e85fb39 + 4fb7afa commit e7b9f10

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Fixed example broker's invalid sync connack call (#869)
44
* Added no CONNACK sending mode to the example broker (#869)
55
* Added posting code to acceptors (#867)
6-
* Added io_context and threads setting options for example broker (#866, #871)
6+
* Added io_context and threads setting options for example broker (#866, #871, #872)
77
* Fixed moved from object access (#865)
88
* <<<< breaking change >>>> Removed ioc_con() and ioc_accept() (#866)
99
* <<<< breaking change >>>> Unified automatic async/sync choosing flag. (#857, #862)

example/broker.conf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ verbose=1
33
certificate=server.crt.pem
44
private_key=server.key.pem
55

6-
iocs=1
7-
threads_per_ioc=1
6+
# 0 means automatic
7+
# Num of vCPU
8+
iocs=0
9+
10+
# 0 means automatic
11+
# min(4 or Num of vCPU)
12+
threads_per_ioc=0
813

914
# Reload interval for the certificate and private key files (hours)
1015
# When configured the broker will perform automatic loading of

example/broker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ void run_broker(boost::program_options::variables_map const& vm) {
350350
return 1;
351351
} ();
352352
if (threads_per_ioc == 0) {
353-
threads_per_ioc = std::max(std::size_t(std::thread::hardware_concurrency()), std::size_t(4));
353+
threads_per_ioc = std::min(std::size_t(std::thread::hardware_concurrency()), std::size_t(4));
354354
MQTT_LOG("mqtt_broker", info) << "threads_per_ioc set to auto decide (0). Automatically set to " << threads_per_ioc;
355355
}
356356

0 commit comments

Comments
 (0)