MCPcopy Create free account
hub / github.com/Vhonowslend/StreamFX-Public / die

Method die

source/util/util-threadpool.cpp:171–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169}
170
171bool streamfx::util::threadpool::threadpool::die(std::shared_ptr<worker_info> wi)
172{
173 constexpr std::chrono::seconds delay{1};
174
175 std::lock_guard<std::mutex> lg(_workers_lock);
176 bool result = false;
177
178 if (_worker_count > _limits.first) {
179 auto now = std::chrono::high_resolution_clock::now();
180 result = ((wi->last_work_time + delay) <= now) && ((_last_worker_death + delay) <= now);
181
182 if (result) {
183 _last_worker_death = now;
184 --_worker_count;
185 _workers.remove(wi);
186 D_LOG_DEBUG("Terminated idle worker thread (%zu < %zu < %zu).", _limits.first, _worker_count.load(), _limits.second);
187 }
188 }
189
190 return result;
191}
192
193void streamfx::util::threadpool::threadpool::work(std::shared_ptr<worker_info> wi)
194{

Callers

nothing calls this directly

Calls 2

removeMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected