Improve automatic I/O thread tuning algorithm

This commit is contained in:
Nik Bougalis
2019-12-15 20:37:10 -08:00
parent 4bb951d48e
commit 3a77990781
2 changed files with 25 additions and 10 deletions

View File

@@ -24,20 +24,22 @@ BasicApp::BasicApp(std::size_t numberOfThreads)
{
work_.emplace (io_service_);
threads_.reserve(numberOfThreads);
while(numberOfThreads--)
threads_.emplace_back(
[this, numberOfThreads]()
{
threads_.emplace_back([this, numberOfThreads]()
{
beast::setCurrentThreadName(
std::string("io_service #") +
std::to_string(numberOfThreads));
this->io_service_.run();
beast::setCurrentThreadName("io svc #" +
std::to_string(numberOfThreads));
this->io_service_.run();
});
}
}
BasicApp::~BasicApp()
{
work_ = boost::none;
for (auto& _ : threads_)
_.join();
for (auto& t : threads_)
t.join();
}