comparison 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
comparison
equal deleted inserted replaced
2793:87b426e54473 2794:f790999a250a
67 #include "Toolbox.h" 67 #include "Toolbox.h"
68 68
69 #include <boost/filesystem.hpp> 69 #include <boost/filesystem.hpp>
70 #include <boost/filesystem/fstream.hpp> 70 #include <boost/filesystem/fstream.hpp>
71 #include <boost/date_time/posix_time/posix_time.hpp> 71 #include <boost/date_time/posix_time/posix_time.hpp>
72 #include <boost/thread.hpp>
72 73
73 74
74 namespace Orthanc 75 namespace Orthanc
75 { 76 {
76 static bool finish_; 77 static bool finish_;
558 559
559 // TODO milliseconds 560 // TODO milliseconds
560 sprintf(s, "%02d%02d%02d.%06d", tm.tm_hour, tm.tm_min, tm.tm_sec, 0); 561 sprintf(s, "%02d%02d%02d.%06d", tm.tm_hour, tm.tm_min, tm.tm_sec, 0);
561 time.assign(s); 562 time.assign(s);
562 } 563 }
564
565
566 unsigned int SystemToolbox::GetHardwareConcurrency()
567 {
568 // Get the number of available hardware threads (e.g. number of
569 // CPUs or cores or hyperthreading units)
570 unsigned int threads = boost::thread::hardware_concurrency();
571
572 if (threads <= 0)
573 {
574 return 1;
575 }
576 else
577 {
578 return threads;
579 }
580 }
563 } 581 }