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

Method ThreadPool

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

Source from the content-addressed store, hash-verified

526}
527
528ThreadPool::ThreadPool()
529 : sp_state_(std::make_shared<ThreadPool::State>()),
530 state_(sp_state_.get()),
531 shutdown_on_destroy_(true) {
532 // Eternal thread pools would produce false leak reports in the vector of
533 // atfork handlers.
534# if !(defined(_WIN32) || defined(ADDRESS_SANITIZER) || defined(ARROW_VALGRIND))
535 state_->atfork_handler_ = std::make_shared<AtForkHandler>(
536 /*before=*/
537 [weak_state = std::weak_ptr<ThreadPool::State>(sp_state_)]() {
538 auto state = weak_state.lock();
539 if (state) {
540 state->BeforeFork();
541 }
542 return state; // passed to after-forkers
543 },
544 /*parent_after=*/
545 [](std::any token) {
546 auto state = std::any_cast<std::shared_ptr<ThreadPool::State>>(token);
547 if (state) {
548 state->ParentAfterFork();
549 }
550 },
551 /*child_after=*/
552 [](std::any token) {
553 auto state = std::any_cast<std::shared_ptr<ThreadPool::State>>(token);
554 if (state) {
555 state->ChildAfterFork();
556 }
557 });
558 RegisterAtFork(state_->atfork_handler_);
559# endif
560}
561
562ThreadPool::~ThreadPool() {
563 if (shutdown_on_destroy_) {

Callers

nothing calls this directly

Calls 5

RegisterAtForkFunction · 0.85
getMethod · 0.45
BeforeForkMethod · 0.45
ParentAfterForkMethod · 0.45
ChildAfterForkMethod · 0.45

Tested by

no test coverage detected