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

Method ThreadPool

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

Source from the content-addressed store, hash-verified

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