Commit 17b89b2a authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

Merge pull request #8770 from alalek:fix_pthreads_default

parents 0831b436 900c4065
......@@ -206,7 +206,6 @@ private:
pthread_mutex_t m_manager_access_mutex;
static const char m_env_name[];
static const unsigned int m_default_number_of_threads;
work_load m_work_load;
......@@ -223,14 +222,6 @@ private:
const char ThreadManager::m_env_name[] = "OPENCV_FOR_THREADS_NUM";
#ifdef ANDROID
// many modern phones/tables have 4-core CPUs. Let's use no more
// than 2 threads by default not to overheat the devices
const unsigned int ThreadManager::m_default_number_of_threads = 2;
#else
const unsigned int ThreadManager::m_default_number_of_threads = 8;
#endif
ForThread::~ForThread()
{
if(m_state == eFTStarted)
......@@ -534,7 +525,15 @@ void ThreadManager::setNumOfThreads(size_t n)
size_t ThreadManager::defaultNumberOfThreads()
{
unsigned int result = m_default_number_of_threads;
#ifdef ANDROID
// many modern phones/tables have 4-core CPUs. Let's use no more
// than 2 threads by default not to overheat the devices
const unsigned int default_number_of_threads = 2;
#else
const unsigned int default_number_of_threads = (unsigned int)std::max(1, cv::getNumberOfCPUs());
#endif
unsigned int result = default_number_of_threads;
char * env = getenv(m_env_name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment