MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / setNumThreads

Method setNumThreads

src/LinearMath/btThreads.cpp:670–695  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

668 return m_numThreads;
669 }
670 virtual void setNumThreads(int numThreads) BT_OVERRIDE
671 {
672 // capping the thread count for PPL due to a thread-index issue
673 const int maxThreadCount = (std::min)(int(BT_MAX_THREAD_COUNT), 31);
674 m_numThreads = (std::max)(1, (std::min)(maxThreadCount, numThreads));
675 using namespace concurrency;
676 if (CurrentScheduler::Id() != -1)
677 {
678 CurrentScheduler::Detach();
679 }
680 SchedulerPolicy policy;
681 {
682 // PPL seems to destroy threads when threadpool is shrunk, but keeps reusing old threads
683 // force it to destroy old threads
684 policy.SetConcurrencyLimits(1, 1);
685 CurrentScheduler::Create(policy);
686 CurrentScheduler::Detach();
687 }
688 policy.SetConcurrencyLimits(m_numThreads, m_numThreads);
689 CurrentScheduler::Create(policy);
690 m_savedThreadCounter = 0;
691 if (m_isActive)
692 {
693 btResetThreadIndexCounter();
694 }
695 }
696 struct ForBodyAdapter
697 {
698 const btIParallelForBody* mBody;

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected