| 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 | { |
nothing calls this directly
no test coverage detected