| 1480 | #endif |
| 1481 | } |
| 1482 | void loop() { |
| 1483 | // the job's memcpys stay off the host's core and the pool's: by default the spare SMT sibling of the last |
| 1484 | // two-thread core (Windows); STRATA_ADAPT_JOB_CPU=<logical cpu>, or -1 for no pinning |
| 1485 | const char* c = std::getenv("STRATA_ADAPT_JOB_CPU"); |
| 1486 | const int cpu = c != nullptr ? std::atoi(c) : smt_spare_cpu(); |
| 1487 | if (cpu >= 0) (void) strata::kernels::cpu::pin_current_thread(cpu); |
| 1488 | for (;;) { |
| 1489 | std::function<void()> f; |
| 1490 | { |
| 1491 | std::unique_lock<std::mutex> lk(mu_); |
| 1492 | cv_.wait(lk, [&] { return has_ || quit_; }); |
| 1493 | if (!has_) return; |
| 1494 | f = std::move(job_); |
| 1495 | has_ = false; |
| 1496 | } |
| 1497 | f(); |
| 1498 | done_.store(true, std::memory_order_release); |
| 1499 | } |
| 1500 | } |
| 1501 | std::mutex mu_; |
| 1502 | std::condition_variable cv_; |
| 1503 | std::function<void()> job_; |
nothing calls this directly
no test coverage detected