MCPcopy Create free account
hub / github.com/cactus-compute/cactus / ThreadPool

Method ThreadPool

cactus/kernel/kernel_utils.h:299–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297
298 public:
299 explicit ThreadPool(size_t num_threads = std::thread::hardware_concurrency())
300 : stop(false), pending_tasks(0) {
301 num_workers_ = std::min(num_threads, MAX_WORKERS);
302 if (num_workers_ == 0) num_workers_ = 1;
303
304#if defined(__ANDROID__)
305 auto& topo = CoreTopology::get();
306 if (!topo.performance_cores.empty()) {
307 num_workers_ = std::min(num_workers_, topo.performance_cores.size());
308 }
309#endif
310
311 workers.reserve(num_workers_);
312 for (size_t i = 0; i < num_workers_; ++i) {
313 workers.emplace_back([this]() {
314#if defined(__ANDROID__)
315 auto& perf = CoreTopology::get().performance_cores;
316 if (!perf.empty()) {
317 pin_current_thread_to_cores(perf);
318 }
319#endif
320 worker_thread();
321 });
322 }
323 }
324
325 ~ThreadPool() {
326 {

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.80

Tested by

no test coverage detected