diff ViewerPlugin/Plugin.cpp @ 153:b798d200ac90

using Semaphore from Orthanc framework
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 27 Jul 2018 14:06:26 +0200
parents 442102e14933
children 32a94bbb7d05
line wrap: on
line diff
--- a/ViewerPlugin/Plugin.cpp	Tue Jul 17 09:55:24 2018 +0200
+++ b/ViewerPlugin/Plugin.cpp	Fri Jul 27 14:06:26 2018 +0200
@@ -23,11 +23,12 @@
 
 #include "DicomPyramidCache.h"
 #include "../Framework/Jpeg2000Reader.h"
-#include "../Framework/Semaphore.h"
 
 #include <Core/Images/ImageProcessing.h>
 #include <Core/Images/PngWriter.h>
+#include <Core/MultiThreading/Semaphore.h>
 #include <Core/OrthancException.h>
+#include <Core/SystemToolbox.h>
 #include <Plugins/Samples/Common/OrthancPluginCppWrapper.h>
 #include <Plugins/Samples/Common/OrthancPluginConnection.h>
 
@@ -39,7 +40,7 @@
 
 std::auto_ptr<OrthancPlugins::OrthancPluginConnection>  orthanc_;
 std::auto_ptr<OrthancWSI::DicomPyramidCache>            cache_;
-std::auto_ptr<OrthancWSI::Semaphore>                    transcoderSemaphore_;
+std::auto_ptr<Orthanc::Semaphore>                       transcoderSemaphore_;
 
 
 static void AnswerSparseTile(OrthancPluginRestOutput* output,
@@ -183,7 +184,7 @@
   // decompress the raw tile
   std::auto_ptr<Orthanc::ImageAccessor> decoded;
 
-  OrthancWSI::Semaphore::Locker locker(*transcoderSemaphore_);
+  Orthanc::Semaphore::Locker locker(*transcoderSemaphore_);
 
   switch (compression)
   {
@@ -312,14 +313,8 @@
     // Limit the number of PNG transcoders to 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)
-    {
-      threads = 1;
-    }
-    
-    transcoderSemaphore_.reset(new OrthancWSI::Semaphore(threads));
+    unsigned int threads = Orthanc::SystemToolbox::GetHardwareConcurrency();
+    transcoderSemaphore_.reset(new Orthanc::Semaphore(threads));
 
     char info[1024];
     sprintf(info, "The whole-slide imaging plugin will use at most %u threads to transcode the tiles", threads);