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

Method Shutdown

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

Source from the content-addressed store, hash-verified

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