FACT++  1.0
bool zofits::SetNumThreads ( uint32_t  num)
inline

Definition at line 600 of file zofits.h.

References ___err___, CompressBuffer(), and gLog.

601  {
602  if (tellp()>0)
603  {
604 #ifdef __EXCEPTIONS
605  throw std::runtime_error("Number of threads cannot be changed in the middle of writing a file");
606 #else
607  gLog << ___err___ << "ERROR - Number of threads cannot be changed in the middle of writing a file" << std::endl;
608 #endif
609  return false;
610  }
611 
612  //get number of physically available threads
613 #ifdef HAVE_BOOST_THREAD
614  unsigned int num_available_cores = boost::thread::hardware_concurrency();
615 #else
616  unsigned int num_available_cores = std::thread::hardware_concurrency();
617  if (num_available_cores == 0)
618  num_available_cores = sysconf(_SC_NPROCESSORS_ONLN);
619 #endif
620  // could not detect number of available cores from system properties...
621  if (num_available_cores == 0)
622  num_available_cores = 1;
623 
624  // leave one core for the main thread and one for the writing
625  if (num > num_available_cores)
626  num = num_available_cores>2 ? num_available_cores-2 : 1;
627 
628  fCompressionQueues.resize(num<1?1:num, Queue<CompressionTarget>(std::bind(&zofits::CompressBuffer, this, std::placeholders::_1), false));
629  fNumQueues = num;
630 
631  return true;
632  }
int32_t fNumQueues
Current number of threads that will be used by this object.
Definition: zofits.h:969
Definition: Queue.h:28
#define gLog
Definition: fits.h:36
#define ___err___
Definition: fits.h:37
std::vector< Queue< CompressionTarget > > fCompressionQueues
Processing queues (=threads)
Definition: zofits.h:973
bool CompressBuffer(const CompressionTarget &target)
Definition: zofits.h:692

+ Here is the call graph for this function: