| 90 | std::condition_variable semaphore_; |
| 91 | |
| 92 | ~ThreadPool() |
| 93 | { |
| 94 | assert(running_); |
| 95 | running_ = false; |
| 96 | |
| 97 | Lock lock(mutex_); |
| 98 | |
| 99 | queue_.clear(); |
| 100 | |
| 101 | semaphore_.notify_all(); |
| 102 | |
| 103 | assert(nullptr != pool_); |
| 104 | for (size_t i = 0; i < size_; ++i) { |
| 105 | TSThread thread = pool_[i]; |
| 106 | assert(nullptr != thread); |
| 107 | Dbg(dbg_ctl, "Destroying thread number %lu (%p)", i, thread); |
| 108 | TSThreadWait(thread); |
| 109 | TSThreadDestroy(thread); |
| 110 | } |
| 111 | |
| 112 | delete[] pool_; |
| 113 | const_cast<TSThread *&>(pool_) = nullptr; |
| 114 | } |
| 115 | |
| 116 | ThreadPool(const size_t s) : size_(s), running_(true), pool_(new TSThread[s]) |
| 117 | { |
nothing calls this directly
no test coverage detected