示例#1
0
void CompilerPool::shutdown(bool detach_compilers) {
  for (int i = 0; i < m_compilers.size(); ++i) {
    if (auto c = m_compilers.exchange(i, nullptr)) {
      if (detach_compilers) {
        c->detach_from_process();
      }
      delete c;
    }
  }
}
示例#2
0
std::pair<size_t, ExternCompiler*> CompilerPool::getCompiler() {
  std::unique_lock<std::mutex> l(m_compilerLock);

  m_compilerCv.wait(l, [&] {
    return m_freeCount.load(std::memory_order_relaxed) != 0;
  });
  m_freeCount -= 1;

  for (size_t id = 0; id < m_compilers.size(); ++id) {
    auto ret = m_compilers.exchange(id, nullptr);
    if (ret) return std::make_pair(id, ret);
  }

  not_reached();
}