diff --git a/rtgui/previewloader.cc b/rtgui/previewloader.cc index 46e1e54a2..c8a5fa337 100644 --- a/rtgui/previewloader.cc +++ b/rtgui/previewloader.cc @@ -21,8 +21,9 @@ #include #include - -#define THREAD_NUM 4 +#ifdef _OPENMP +#include +#endif #define DEBUG(format,args...) //#define DEBUG(format,args...) printf("PreviewLoader::%s: " format "\n", __FUNCTION__, ## args) @@ -62,9 +63,15 @@ public: typedef std::set JobSet; - Impl(): - threadPool_(new Glib::ThreadPool(THREAD_NUM,0)) - {} + Impl() + { + int threadCount=1; + #ifdef _OPENMP + threadCount=omp_get_num_procs(); + #endif + + threadPool_=new Glib::ThreadPool(threadCount,0); + } Glib::ThreadPool* threadPool_; diff --git a/rtgui/thumbimageupdater.cc b/rtgui/thumbimageupdater.cc index 2b83a7157..38720095f 100644 --- a/rtgui/thumbimageupdater.cc +++ b/rtgui/thumbimageupdater.cc @@ -22,7 +22,9 @@ #include #include -#define THREAD_NUM 2 +#ifdef _OPENMP +#include +#endif #define DEBUG(format,args...) //#define DEBUG(format,args...) printf("ThumbImageUpdate::%s: " format "\n", __FUNCTION__, ## args) @@ -61,10 +63,16 @@ public: typedef std::list JobList; Impl(): - threadPool_(new Glib::ThreadPool(THREAD_NUM,0)), active_(0), inactive_waiting_(false) - {} + { + int threadCount=1; + #ifdef _OPENMP + threadCount=omp_get_num_procs(); + #endif + + threadPool_=new Glib::ThreadPool(threadCount,0); + } Glib::ThreadPool* threadPool_;