diff Applications/StoneApplicationContext.h @ 431:26b90b110719 am-vsol-upgrade

added DelayedCallExecutor to avoid using sleep() in C++ that consumes 100% CPU once executed in WASM
author am@osimis.io
date Thu, 29 Nov 2018 19:25:15 +0100
parents c23df8b3433b
children a750f11892ec
line wrap: on
line diff
--- a/Applications/StoneApplicationContext.h	Thu Nov 29 15:11:19 2018 +0100
+++ b/Applications/StoneApplicationContext.h	Thu Nov 29 19:25:15 2018 +0100
@@ -22,6 +22,7 @@
 #pragma once
 
 #include "../Framework/Toolbox/IWebService.h"
+#include "../Framework/Toolbox/IDelayedCallExecutor.h"
 #include "../Framework/Toolbox/OrthancApiClient.h"
 #include "../Framework/Viewport/WidgetViewport.h"
 
@@ -41,6 +42,7 @@
   private:
     MessageBroker&                   broker_;
     IWebService*                     webService_;
+    IDelayedCallExecutor*            delayedCallExecutor_;
     std::auto_ptr<OrthancApiClient>  orthanc_;
     std::string                      orthancBaseUrl_;
 
@@ -49,7 +51,8 @@
   public:
     StoneApplicationContext(MessageBroker& broker) :
       broker_(broker),
-      webService_(NULL)
+      webService_(NULL),
+      delayedCallExecutor_(NULL)
     {
     }
 
@@ -74,5 +77,15 @@
     void SetWebService(IWebService& webService);
 
     void SetOrthancBaseUrl(const std::string& baseUrl);
+
+    void SetDelayedCallExecutor(IDelayedCallExecutor& delayedCallExecutor)
+    {
+      delayedCallExecutor_ = &delayedCallExecutor;
+    }
+
+    IDelayedCallExecutor& GetDelayedCallExecutor()
+    {
+      return *delayedCallExecutor_;
+    }
   };
 }