| 32 | } |
| 33 | |
| 34 | void io_context_pool::run() |
| 35 | { |
| 36 | // Create a pool of threads to run all of the io_contexts. |
| 37 | std::vector<std::thread> threads; |
| 38 | for (std::size_t i = 0; i < io_contexts_.size(); ++i) |
| 39 | threads.emplace_back([this, i]{ io_contexts_[i]->run(); }); |
| 40 | |
| 41 | // Wait for all threads in the pool to exit. |
| 42 | for (std::size_t i = 0; i < threads.size(); ++i) |
| 43 | threads[i].join(); |
| 44 | } |
| 45 | |
| 46 | void io_context_pool::stop() |
| 47 | { |