Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
thread_utils.cpp
Go to the documentation of this file.
3
4namespace sysio { namespace chain {
5
6
7//
8// named_thread_pool
9//
10named_thread_pool::named_thread_pool( std::string name_prefix, size_t num_threads )
11: _thread_pool( num_threads )
12, _ioc( num_threads )
13{
14 _ioc_work.emplace( boost::asio::make_work_guard( _ioc ) );
15 for( size_t i = 0; i < num_threads; ++i ) {
16 boost::asio::post( _thread_pool, [&ioc = _ioc, name_prefix, i]() {
17 std::string tn = name_prefix + "-" + std::to_string( i );
19 ioc.run();
20 } );
21 }
22}
23
27
29 _ioc_work.reset();
30 _ioc.stop();
31 _thread_pool.join();
32 _thread_pool.stop();
33}
34
35
36} } // sysio::chain
named_thread_pool(std::string name_prefix, size_t num_threads)
void set_os_thread_name(const string &name)