Salome HOME
Solve problem of non install of includes of src/engine/.hxx into install/include...
[modules/yacs.git] / src / engine / Runtime.cxx
index 61a354fdd3af003a08761f2fe99c6cb6b502256e..48776eabd21d7f9115fcfe69c7cc7c06c5814d68 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2006-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2016  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -86,15 +86,10 @@ Runtime::Runtime()
   DEBTRACE( "_tc_stringpair refcnt: " << Runtime::_tc_stringpair->getRefCnt() );
   DEBTRACE( "_tc_propvec refcnt: " << Runtime::_tc_propvec->getRefCnt() );
   _builtinCatalog = new Catalog("builtins");
-  _builtinCatalog->_composednodeMap["Bloc"]=createBloc("Bloc");
-  _builtinCatalog->_composednodeMap["Switch"]=createSwitch("Switch");
-  _builtinCatalog->_composednodeMap["WhileLoop"]=createWhileLoop("WhileLoop");
-  _builtinCatalog->_composednodeMap["ForLoop"]=createForLoop("ForLoop");
-  _builtinCatalog->_composednodeMap["ForEachLoop_double"]=createForEachLoop("ForEachLoop_double",Runtime::_tc_double);
-  _builtinCatalog->_composednodeMap["ForEachLoop_string"]=createForEachLoop("ForEachLoop_string",Runtime::_tc_string);
-  _builtinCatalog->_composednodeMap["ForEachLoop_int"]=createForEachLoop("ForEachLoop_int",Runtime::_tc_int);
-  _builtinCatalog->_composednodeMap["ForEachLoop_bool"]=createForEachLoop("ForEachLoop_bool",Runtime::_tc_bool);
   std::map<std::string,TypeCode*>& typeMap=_builtinCatalog->_typeMap;
+  /* All composed node creations are moved to RuntimeSALOME::initBuiltins.
+     It is not safe to have all those calls to virtual functions (create*)
+     in the constructor. */
   Runtime::_tc_double->incrRef();
   typeMap["double"]=Runtime::_tc_double;
   Runtime::_tc_int->incrRef();
@@ -123,11 +118,21 @@ Runtime::Runtime()
 
   // Get max threads number
   char *maxThreadStr = getenv("YACS_MAX_THREADS");
-  if (!maxThreadStr) return;
-  int maxThreads = atoi(maxThreadStr);
-  DEBTRACE("maxThreads = " << maxThreads);
-  if (maxThreads <1) return;
-  Executor::_maxThreads = maxThreads;
+  if (maxThreadStr != NULL)
+    {
+      int maxThreads = atoi(maxThreadStr);
+      DEBTRACE("maxThreads = " << maxThreads);
+      if (maxThreads > 0) Executor::_maxThreads = maxThreads;
+    }
+
+  // Get thread stack size
+  char *threadStackSizeStr = getenv("YACS_THREADS_STACK_SIZE");
+  if (threadStackSizeStr != NULL)
+    {
+      size_t threadStackSize = strtoul(threadStackSizeStr, NULL, 0);
+      DEBTRACE("threadStackSize = " << threadStackSize);
+      if (threadStackSize > 0) Executor::_threadStackSize = threadStackSize;
+    }
 }
 
 void Runtime::removeRuntime()
@@ -245,7 +250,9 @@ ForLoop* Runtime::createForLoop(const std::string& name)
 
 ForEachLoop* Runtime::createForEachLoop(const std::string& name,TypeCode *type)
 {
-  return new ForEachLoop(name,type);
+  ForEachLoop* ret = new ForEachLoop(name,type);
+  ret->edGetNbOfBranchesPort()->edInit(1);
+  return ret;
 }
 
 OptimizerLoop* Runtime::createOptimizerLoop(const std::string& name,const std::string& algLib,const std::string& factoryName,bool algInitOnFile,