-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
@arvidn I found a lot of std::thread in the code.
Creating a thread is a very expensive command. You need to optimize the creation of all threads (except for disk_io_thread_pool) using thread_pool.
Like this:
ThreadPool.hpp:
#pragma once
#include <boost/asio/thread_pool.hpp>
extern boost::asio::thread_pool mainPool;
ThreadPool.cpp:
unsigned n = std::thread::hardware_concurrency();
if (n == 0) n = 4;
boost::asio::thread_pool pool(n);
And after:
#include "ThreadPool.hpp"
#include <boost/asio/post.hpp>
void doTask() {
boost::asio::post(pool, []{
....
});
}
This can significantly increase the speed of the library. And any of your programs.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels