Skip to content

Commit

Permalink
Merge pull request #872 from redboltz/fix_auto_threads_per_ioc
Browse files Browse the repository at this point in the history
Fixed automatic threads_per_ioc logic.
  • Loading branch information
redboltz committed Sep 27, 2021
2 parents e85fb39 + 4fb7afa commit e7b9f10
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Fixed example broker's invalid sync connack call (#869)
* Added no CONNACK sending mode to the example broker (#869)
* Added posting code to acceptors (#867)
* Added io_context and threads setting options for example broker (#866, #871)
* Added io_context and threads setting options for example broker (#866, #871, #872)
* Fixed moved from object access (#865)
* <<<< breaking change >>>> Removed ioc_con() and ioc_accept() (#866)
* <<<< breaking change >>>> Unified automatic async/sync choosing flag. (#857, #862)
Expand Down
9 changes: 7 additions & 2 deletions example/broker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ verbose=1
certificate=server.crt.pem
private_key=server.key.pem

iocs=1
threads_per_ioc=1
# 0 means automatic
# Num of vCPU
iocs=0

# 0 means automatic
# min(4 or Num of vCPU)
threads_per_ioc=0

# Reload interval for the certificate and private key files (hours)
# When configured the broker will perform automatic loading of
Expand Down
2 changes: 1 addition & 1 deletion example/broker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ void run_broker(boost::program_options::variables_map const& vm) {
return 1;
} ();
if (threads_per_ioc == 0) {
threads_per_ioc = std::max(std::size_t(std::thread::hardware_concurrency()), std::size_t(4));
threads_per_ioc = std::min(std::size_t(std::thread::hardware_concurrency()), std::size_t(4));
MQTT_LOG("mqtt_broker", info) << "threads_per_ioc set to auto decide (0). Automatically set to " << threads_per_ioc;
}

Expand Down

0 comments on commit e7b9f10

Please sign in to comment.