diff Core/SystemToolbox.cpp @ 2794:f790999a250a

Semaphore removed from graveyard, SystemToolbox::GetHardwareConcurrency()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 27 Jul 2018 14:01:02 +0200
parents 4dcafa8d6633
children 2a504fef4ed7
line wrap: on
line diff
--- a/Core/SystemToolbox.cpp	Thu Jul 26 22:11:36 2018 +0200
+++ b/Core/SystemToolbox.cpp	Fri Jul 27 14:01:02 2018 +0200
@@ -69,6 +69,7 @@
 #include <boost/filesystem.hpp>
 #include <boost/filesystem/fstream.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/thread.hpp>
 
 
 namespace Orthanc
@@ -560,4 +561,21 @@
     sprintf(s, "%02d%02d%02d.%06d", tm.tm_hour, tm.tm_min, tm.tm_sec, 0);
     time.assign(s);
   }
+
+  
+  unsigned int SystemToolbox::GetHardwareConcurrency()
+  {
+    // Get the number of available hardware threads (e.g. number of
+    // CPUs or cores or hyperthreading units)
+    unsigned int threads = boost::thread::hardware_concurrency();
+    
+    if (threads <= 0)
+    {
+      return 1;
+    }
+    else
+    {
+      return threads;
+    }
+  }
 }