| 241 | |
| 242 | template <typename Thread> |
| 243 | void ThreadPoolImpl<Thread>::setMaxFreeThreads(size_t value) |
| 244 | { |
| 245 | value = std::min(value, static_cast<size_t>(MAX_THEORETICAL_THREAD_COUNT)); |
| 246 | std::lock_guard lock(mutex); |
| 247 | bool need_finish_free_threads = (value < max_free_threads); |
| 248 | |
| 249 | max_free_threads = std::min(value, max_threads); |
| 250 | |
| 251 | if (need_finish_free_threads) |
| 252 | { |
| 253 | /// Wake exactly the excess idle threads so they can observe the new limit |
| 254 | /// and exit. We do not call `wakeUpAllIdleThreadsNoLock` here because that |
| 255 | /// would wipe the LIFO stack on every limit adjustment, defeating the |
| 256 | /// purpose of LIFO scheduling. |
| 257 | wakeUpExcessIdleThreadsNoLock(); |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | template <typename Thread> |
| 262 | void ThreadPoolImpl<Thread>::setQueueSize(size_t value) |