Ensures that the pool has at least the given count of threads. If any new thread has to be created, this function waits for it to be ready.
| 181 | // If any new thread has to be created, this function waits for it to |
| 182 | // be ready. |
| 183 | void ThreadPool::CreateThreads(int threads_count) { |
| 184 | if (threads_.size() >= threads_count) { |
| 185 | return; |
| 186 | } |
| 187 | counter_to_decrement_when_ready_.Reset(threads_count - threads_.size()); |
| 188 | while (threads_.size() < threads_count) { |
| 189 | threads_.push_back(new Thread(&counter_to_decrement_when_ready_)); |
| 190 | } |
| 191 | counter_to_decrement_when_ready_.Wait(); |
| 192 | } |
| 193 | |
| 194 | ThreadPool::~ThreadPool() { |
| 195 | for (auto w : threads_) { |