| 694 | bool ThreadPool::OwnsThisThread() { return GetCurrentThreadPool() == this; } |
| 695 | |
| 696 | Status ThreadPool::LaunchWorkersUnlocked(int threads) { |
| 697 | std::shared_ptr<State> state = sp_state_; |
| 698 | |
| 699 | for (int i = 0; i < threads; i++) { |
| 700 | state_->workers_.emplace_back(); |
| 701 | auto it = --(state_->workers_.end()); |
| 702 | try { |
| 703 | *it = std::thread([this, state, it] { |
| 704 | SetCurrentThreadPool(this); |
| 705 | WorkerLoop(state, it); |
| 706 | }); |
| 707 | } catch (const std::exception& e) { |
| 708 | state_->workers_.erase(it); |
| 709 | return Status::UnknownError("Failed to launch worker thread: ", e.what()); |
| 710 | } |
| 711 | } |
| 712 | return Status::OK(); |
| 713 | } |
| 714 | |
| 715 | Status ThreadPool::SpawnReal(TaskHints hints, FnOnce<void()> task, StopToken stop_token, |
| 716 | StopCallback&& stop_callback) { |
nothing calls this directly
no test coverage detected