MCPcopy Create free account
hub / github.com/chrxh/alien / worker

Class worker

external/cpp-httplib/httplib.h:572–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

570
571 private:
572 struct worker {
573 explicit worker(ThreadPool& pool) : pool_(pool) {}
574
575 void operator()() {
576 for (;;) {
577 std::function<void()> fn;
578 {
579 std::unique_lock<std::mutex> lock(pool_.mutex_);
580
581 pool_.cond_.wait(
582 lock, [&] { return !pool_.jobs_.empty() || pool_.shutdown_; });
583
584 if (pool_.shutdown_ && pool_.jobs_.empty()) { break; }
585
586 fn = pool_.jobs_.front();
587 pool_.jobs_.pop_front();
588 }
589
590 assert(true == static_cast<bool>(fn));
591 fn();
592 }
593 }
594
595 ThreadPool& pool_;
596 };
597 friend struct worker;
598
599 std::vector<std::thread> threads_;

Callers 1

ThreadPoolMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected