diff Applications/Generic/NativeStoneApplicationRunner.cpp @ 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/Generic/NativeStoneApplicationRunner.cpp	Thu Nov 29 15:11:19 2018 +0100
+++ b/Applications/Generic/NativeStoneApplicationRunner.cpp	Thu Nov 29 19:25:15 2018 +0100
@@ -27,6 +27,7 @@
 
 #include "../../Framework/Toolbox/MessagingToolbox.h"
 #include "../../Platforms/Generic/OracleWebService.h"
+#include "../../Platforms/Generic/OracleDelayedCallExecutor.h"
 #include "NativeStoneApplicationContext.h"
 
 #include <Core/Logging.h>
@@ -188,7 +189,7 @@
       NativeStoneApplicationContext context(broker_);
 
       {
-        Oracle oracle(4); // use 4 threads to download content
+        Oracle oracle(6); // use multiple threads to execute asynchronous tasks like download content
         oracle.Start();
 
         {
@@ -196,6 +197,9 @@
           context.SetWebService(webService);
           context.SetOrthancBaseUrl(webServiceParameters.GetUrl());
 
+          OracleDelayedCallExecutor delayedExecutor(broker_, oracle, context);
+          context.SetDelayedCallExecutor(delayedExecutor);
+
           application_.Initialize(&context, statusBar, parameters);
 
           {