MCPcopy Create free account
hub / github.com/apache/arrow / Shutdown

Method Shutdown

cpp/src/arrow/util/thread_pool.cc:607–625  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

605}
606
607Status ThreadPool::Shutdown(bool wait) {
608 std::unique_lock<std::mutex> lock(state_->mutex_);
609
610 if (state_->please_shutdown_) {
611 return Status::Invalid("Shutdown() already called");
612 }
613 state_->please_shutdown_ = true;
614 state_->quick_shutdown_ = !wait;
615 state_->cv_.notify_all();
616 state_->cv_shutdown_.wait(lock, [this] { return state_->workers_.empty(); });
617 if (!state_->quick_shutdown_) {
618 DCHECK_EQ(state_->pending_tasks_.size(), 0);
619 } else {
620 std::priority_queue<QueuedTask> empty;
621 std::swap(state_->pending_tasks_, empty);
622 }
623 CollectFinishedWorkersUnlocked();
624 return Status::OK();
625}
626
627void ThreadPool::CollectFinishedWorkersUnlocked() {
628 for (auto& thread : state_->finished_workers_) {

Callers 11

ThreadPoolSpawnFunction · 0.45
ThreadPoolSubmitFunction · 0.45
ThreadedTaskGroupFunction · 0.45
TEST_PFunction · 0.45
TearDownMethod · 0.45
TEST_FFunction · 0.45
~SignalStopStateMethod · 0.45
DoSpawnAddsMethod · 0.45
DoSpawnAddsThreadedMethod · 0.45
TEST_FFunction · 0.45
ASSERT_OK_AND_ASSIGNFunction · 0.45

Calls 5

swapFunction · 0.85
InvalidFunction · 0.50
OKFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45

Tested by 7

TEST_PFunction · 0.36
TearDownMethod · 0.36
TEST_FFunction · 0.36
DoSpawnAddsMethod · 0.36
DoSpawnAddsThreadedMethod · 0.36
TEST_FFunction · 0.36
ASSERT_OK_AND_ASSIGNFunction · 0.36