changeset 5412:1a351a141653

ServerContextLock -> ServerContextReference to allow multiple plugins to use it at the same time
author Alain Mazy <am@osimis.io>
date Wed, 08 Nov 2023 08:55:42 +0100
parents ca9cf4d46883
children 342b25e120d1
files OrthancServer/Plugins/Engine/OrthancPlugins.cpp OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h
diffstat 3 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Plugins/Engine/OrthancPlugins.cpp	Wed Nov 08 08:34:47 2023 +0100
+++ b/OrthancServer/Plugins/Engine/OrthancPlugins.cpp	Wed Nov 08 08:55:42 2023 +0100
@@ -1491,7 +1491,7 @@
       ~ServerContextReference()
       {
         boost::mutex::scoped_lock lock(mutex_);
-        refCount_++;
+        refCount_--;
         cond_.notify_one();
       }
 
--- a/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Wed Nov 08 08:34:47 2023 +0100
+++ b/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Wed Nov 08 08:55:42 2023 +0100
@@ -79,6 +79,10 @@
     }
   }
 
+  void ResetGlobalContext()
+  {
+    globalContext_ = NULL;
+  }
 
   bool HasGlobalContext()
   {
--- a/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Wed Nov 08 08:34:47 2023 +0100
+++ b/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Wed Nov 08 08:55:42 2023 +0100
@@ -137,6 +137,8 @@
 
   void SetGlobalContext(OrthancPluginContext* context);
 
+  void ResetGlobalContext();
+
   bool HasGlobalContext();
 
   OrthancPluginContext* GetGlobalContext();