MCPcopy Create free account
hub / github.com/aui-framework/aui / setWorkersCount

Method setWorkersCount

aui.core/src/AUI/Thread/AThreadPool.cpp:161–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161void AThreadPool::setWorkersCount(std::size_t workersCount) {
162 AUI_ASSERTX(workersCount >= 2 && workersCount <= 1000, "invalid worker count");
163 std::unique_lock lck(mQueueLock);
164 if (mWorkers.size() >= workersCount) {
165 while (mWorkers.size() > workersCount) {
166 mCV.notify_all();
167 mWorkers.last()->aboutToDelete();
168 lck.unlock();
169 mWorkers.pop_back();
170 lck.lock();
171 }
172 } else {
173 // have to add new workers
174 mWorkers.reserve(workersCount);
175 while (mWorkers.size() < workersCount) {
176 mWorkers.push_back(std::make_unique<Worker>(*this, mWorkers.size()));
177 }
178 }
179}
180
181size_t AThreadPool::getPendingTaskCount() { return mQueueHighest.size() + mQueueLowest.size() + mQueueMedium.size(); }

Callers

nothing calls this directly

Calls 9

notify_allMethod · 0.80
aboutToDeleteMethod · 0.80
lastMethod · 0.80
sizeMethod · 0.45
unlockMethod · 0.45
pop_backMethod · 0.45
lockMethod · 0.45
reserveMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected