ThreadManagement class added to store and use all mutex/signal 55/16155/8
Cedric Delamarre [Fri, 13 Mar 2015 14:18:34 +0000 (15:18 +0100)]
Change-Id: Iab723985247ed4b8965476039bd3c94ab4153ecd

18 files changed:
scilab/modules/ast/Makefile.am
scilab/modules/ast/Makefile.in
scilab/modules/ast/ast.vcxproj
scilab/modules/ast/ast.vcxproj.filters
scilab/modules/ast/core_Import.def
scilab/modules/ast/includes/system_env/threadmanagement.hxx [new file with mode: 0644]
scilab/modules/ast/src/cpp/ast/runvisitor.cpp
scilab/modules/ast/src/cpp/system_env/threadmanagement.cpp [new file with mode: 0644]
scilab/modules/ast/threads_Import.def [deleted file]
scilab/modules/console/src/c/GetCommandLine.c
scilab/modules/console/src/c/core_Import.def
scilab/modules/core/includes/runner.hxx
scilab/modules/core/sci_gateway/cpp/sci_pause.cpp
scilab/modules/core/src/cpp/InitScilab.cpp
scilab/modules/core/src/cpp/runner.cpp
scilab/modules/core/src/cpp/storeCommand.cpp
scilab/modules/functions/sci_gateway/cpp/sci_exec.cpp
scilab/modules/functions/sci_gateway/cpp/sci_execstr.cpp

index f7242ed..56f59b3 100644 (file)
@@ -67,6 +67,7 @@ src/cpp/system_env/sci_home.cpp \
 src/cpp/system_env/sci_path.cpp \
 src/cpp/system_env/sci_tmpdir.cpp \
 src/cpp/system_env/setenvvar.cpp \
+src/cpp/system_env/threadmanagement.cpp \
 src/cpp/types/addfunction.cpp \
 src/cpp/types/arrayof.cpp \
 src/cpp/types/bool.cpp \
index 6d5dcf7..a6a8267 100644 (file)
@@ -205,15 +205,16 @@ am__libsciast_la_SOURCES_DIST = src/c/operations/doublecomplex.c \
        src/cpp/system_env/sci_home.cpp \
        src/cpp/system_env/sci_path.cpp \
        src/cpp/system_env/sci_tmpdir.cpp \
-       src/cpp/system_env/setenvvar.cpp src/cpp/types/addfunction.cpp \
-       src/cpp/types/arrayof.cpp src/cpp/types/bool.cpp \
-       src/cpp/types/callable.cpp src/cpp/types/cell.cpp \
-       src/cpp/types/double.cpp src/cpp/types/file.cpp \
-       src/cpp/types/function.cpp src/cpp/types/graphichandle.cpp \
-       src/cpp/types/implicitlist.cpp src/cpp/types/int.cpp \
-       src/cpp/types/library.cpp src/cpp/types/list.cpp \
-       src/cpp/types/listdelete.cpp src/cpp/types/listinsert.cpp \
-       src/cpp/types/listoperation.cpp \
+       src/cpp/system_env/setenvvar.cpp \
+       src/cpp/system_env/threadmanagement.cpp \
+       src/cpp/types/addfunction.cpp src/cpp/types/arrayof.cpp \
+       src/cpp/types/bool.cpp src/cpp/types/callable.cpp \
+       src/cpp/types/cell.cpp src/cpp/types/double.cpp \
+       src/cpp/types/file.cpp src/cpp/types/function.cpp \
+       src/cpp/types/graphichandle.cpp src/cpp/types/implicitlist.cpp \
+       src/cpp/types/int.cpp src/cpp/types/library.cpp \
+       src/cpp/types/list.cpp src/cpp/types/listdelete.cpp \
+       src/cpp/types/listinsert.cpp src/cpp/types/listoperation.cpp \
        src/cpp/types/listundefined.cpp src/cpp/types/macro.cpp \
        src/cpp/types/macrofile.cpp src/cpp/types/mlist.cpp \
        src/cpp/types/overload.cpp src/cpp/types/polynom.cpp \
@@ -297,6 +298,7 @@ am_libsciast_la_OBJECTS =  \
        src/cpp/system_env/libsciast_la-sci_path.lo \
        src/cpp/system_env/libsciast_la-sci_tmpdir.lo \
        src/cpp/system_env/libsciast_la-setenvvar.lo \
+       src/cpp/system_env/libsciast_la-threadmanagement.lo \
        src/cpp/types/libsciast_la-addfunction.lo \
        src/cpp/types/libsciast_la-arrayof.lo \
        src/cpp/types/libsciast_la-bool.lo \
@@ -766,15 +768,16 @@ libsciast_la_SOURCES = src/c/operations/doublecomplex.c \
        src/cpp/system_env/sci_home.cpp \
        src/cpp/system_env/sci_path.cpp \
        src/cpp/system_env/sci_tmpdir.cpp \
-       src/cpp/system_env/setenvvar.cpp src/cpp/types/addfunction.cpp \
-       src/cpp/types/arrayof.cpp src/cpp/types/bool.cpp \
-       src/cpp/types/callable.cpp src/cpp/types/cell.cpp \
-       src/cpp/types/double.cpp src/cpp/types/file.cpp \
-       src/cpp/types/function.cpp src/cpp/types/graphichandle.cpp \
-       src/cpp/types/implicitlist.cpp src/cpp/types/int.cpp \
-       src/cpp/types/library.cpp src/cpp/types/list.cpp \
-       src/cpp/types/listdelete.cpp src/cpp/types/listinsert.cpp \
-       src/cpp/types/listoperation.cpp \
+       src/cpp/system_env/setenvvar.cpp \
+       src/cpp/system_env/threadmanagement.cpp \
+       src/cpp/types/addfunction.cpp src/cpp/types/arrayof.cpp \
+       src/cpp/types/bool.cpp src/cpp/types/callable.cpp \
+       src/cpp/types/cell.cpp src/cpp/types/double.cpp \
+       src/cpp/types/file.cpp src/cpp/types/function.cpp \
+       src/cpp/types/graphichandle.cpp src/cpp/types/implicitlist.cpp \
+       src/cpp/types/int.cpp src/cpp/types/library.cpp \
+       src/cpp/types/list.cpp src/cpp/types/listdelete.cpp \
+       src/cpp/types/listinsert.cpp src/cpp/types/listoperation.cpp \
        src/cpp/types/listundefined.cpp src/cpp/types/macro.cpp \
        src/cpp/types/macrofile.cpp src/cpp/types/mlist.cpp \
        src/cpp/types/overload.cpp src/cpp/types/polynom.cpp \
@@ -1364,6 +1367,9 @@ src/cpp/system_env/libsciast_la-sci_tmpdir.lo:  \
 src/cpp/system_env/libsciast_la-setenvvar.lo:  \
        src/cpp/system_env/$(am__dirstamp) \
        src/cpp/system_env/$(DEPDIR)/$(am__dirstamp)
+src/cpp/system_env/libsciast_la-threadmanagement.lo:  \
+       src/cpp/system_env/$(am__dirstamp) \
+       src/cpp/system_env/$(DEPDIR)/$(am__dirstamp)
 src/cpp/types/$(am__dirstamp):
        @$(MKDIR_P) src/cpp/types
        @: > src/cpp/types/$(am__dirstamp)
@@ -1615,6 +1621,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/system_env/$(DEPDIR)/libsciast_la-sci_path.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/system_env/$(DEPDIR)/libsciast_la-sci_tmpdir.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/system_env/$(DEPDIR)/libsciast_la-setenvvar.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/system_env/$(DEPDIR)/libsciast_la-threadmanagement.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/types/$(DEPDIR)/libsciast_la-addfunction.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/types/$(DEPDIR)/libsciast_la-arrayof.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/types/$(DEPDIR)/libsciast_la-bool.Plo@am__quote@
@@ -2070,6 +2077,13 @@ src/cpp/system_env/libsciast_la-setenvvar.lo: src/cpp/system_env/setenvvar.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/system_env/libsciast_la-setenvvar.lo `test -f 'src/cpp/system_env/setenvvar.cpp' || echo '$(srcdir)/'`src/cpp/system_env/setenvvar.cpp
 
+src/cpp/system_env/libsciast_la-threadmanagement.lo: src/cpp/system_env/threadmanagement.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/system_env/libsciast_la-threadmanagement.lo -MD -MP -MF src/cpp/system_env/$(DEPDIR)/libsciast_la-threadmanagement.Tpo -c -o src/cpp/system_env/libsciast_la-threadmanagement.lo `test -f 'src/cpp/system_env/threadmanagement.cpp' || echo '$(srcdir)/'`src/cpp/system_env/threadmanagement.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/system_env/$(DEPDIR)/libsciast_la-threadmanagement.Tpo src/cpp/system_env/$(DEPDIR)/libsciast_la-threadmanagement.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/system_env/threadmanagement.cpp' object='src/cpp/system_env/libsciast_la-threadmanagement.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/system_env/libsciast_la-threadmanagement.lo `test -f 'src/cpp/system_env/threadmanagement.cpp' || echo '$(srcdir)/'`src/cpp/system_env/threadmanagement.cpp
+
 src/cpp/types/libsciast_la-addfunction.lo: src/cpp/types/addfunction.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/types/libsciast_la-addfunction.lo -MD -MP -MF src/cpp/types/$(DEPDIR)/libsciast_la-addfunction.Tpo -c -o src/cpp/types/libsciast_la-addfunction.lo `test -f 'src/cpp/types/addfunction.cpp' || echo '$(srcdir)/'`src/cpp/types/addfunction.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/types/$(DEPDIR)/libsciast_la-addfunction.Tpo src/cpp/types/$(DEPDIR)/libsciast_la-addfunction.Plo
index e0a419c..d3484eb 100644 (file)
       <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ImportLibrary>../../bin/$(ProjectName).lib</ImportLibrary>
-      <AdditionalDependencies>fileio.lib;dynamic_link.lib;sciconsole.lib;threads.lib;output_stream.lib;core.lib;io.lib;elementary_functions_f.lib;elementary_functions.lib;polynomials_f.lib;linear_algebra_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>fileio.lib;dynamic_link.lib;sciconsole.lib;output_stream.lib;core.lib;io.lib;elementary_functions_f.lib;elementary_functions.lib;polynomials_f.lib;linear_algebra_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <RandomizedBaseAddress>false</RandomizedBaseAddress>
     </Link>
     <PreLinkEvent>
@@ -121,7 +121,6 @@ lib /DEF:"$(ProjectDir)linear_algebra_f_import.def" /SUBSYSTEM:WINDOWS /MACHINE:
 lib /DEF:"$(ProjectDir)polynomials_f_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)polynomials_f.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)io_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)io.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)output_stream_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)output_stream.lib" 1&gt;NUL 2&gt;NUL
-lib /DEF:"$(ProjectDir)threads_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)threads.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)console_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)sciconsole.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)dynamic_link_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)dynamic_link.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)fileio_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)fileio.lib" 1&gt;NUL 2&gt;NUL
@@ -148,7 +147,7 @@ lib /DEF:"$(ProjectDir)fileio_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
       <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <ImportLibrary>../../bin/$(ProjectName).lib</ImportLibrary>
-      <AdditionalDependencies>fileio.lib;dynamic_link.lib;sciconsole.lib;threads.lib;output_stream.lib;core.lib;io.lib;elementary_functions_f.lib;elementary_functions.lib;polynomials_f.lib;linear_algebra_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>fileio.lib;dynamic_link.lib;sciconsole.lib;output_stream.lib;core.lib;io.lib;elementary_functions_f.lib;elementary_functions.lib;polynomials_f.lib;linear_algebra_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <RandomizedBaseAddress>false</RandomizedBaseAddress>
     </Link>
     <PreLinkEvent>
@@ -159,7 +158,6 @@ lib /DEF:"$(ProjectDir)linear_algebra_f_import.def" /SUBSYSTEM:WINDOWS /MACHINE:
 lib /DEF:"$(ProjectDir)polynomials_f_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)polynomials_f.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)io_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)io.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)output_stream_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)output_stream.lib" 1&gt;NUL 2&gt;NUL
-lib /DEF:"$(ProjectDir)threads_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)threads.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)console_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)sciconsole.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)dynamic_link_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)dynamic_link.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)fileio_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)fileio.lib" 1&gt;NUL 2&gt;NUL
@@ -183,7 +181,7 @@ lib /DEF:"$(ProjectDir)fileio_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
     <Link>
       <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
       <ImportLibrary>../../bin/$(ProjectName).lib</ImportLibrary>
-      <AdditionalDependencies>fileio.lib;dynamic_link.lib;sciconsole.lib;threads.lib;output_stream.lib;core.lib;io.lib;elementary_functions_f.lib;elementary_functions.lib;polynomials_f.lib;linear_algebra_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>fileio.lib;dynamic_link.lib;sciconsole.lib;output_stream.lib;core.lib;io.lib;elementary_functions_f.lib;elementary_functions.lib;polynomials_f.lib;linear_algebra_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <RandomizedBaseAddress>false</RandomizedBaseAddress>
     </Link>
     <PreLinkEvent>
@@ -194,7 +192,6 @@ lib /DEF:"$(ProjectDir)linear_algebra_f_import.def" /SUBSYSTEM:WINDOWS /MACHINE:
 lib /DEF:"$(ProjectDir)polynomials_f_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)polynomials_f.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)io_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)io.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)output_stream_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)output_stream.lib" 1&gt;NUL 2&gt;NUL
-lib /DEF:"$(ProjectDir)threads_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)threads.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)console_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)sciconsole.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)dynamic_link_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)dynamic_link.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)fileio_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)fileio.lib" 1&gt;NUL 2&gt;NUL
@@ -221,7 +218,7 @@ lib /DEF:"$(ProjectDir)fileio_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
     <Link>
       <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
       <ImportLibrary>../../bin/$(ProjectName).lib</ImportLibrary>
-      <AdditionalDependencies>fileio.lib;dynamic_link.lib;sciconsole.lib;threads.lib;output_stream.lib;core.lib;io.lib;elementary_functions_f.lib;elementary_functions.lib;polynomials_f.lib;linear_algebra_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>fileio.lib;dynamic_link.lib;sciconsole.lib;output_stream.lib;core.lib;io.lib;elementary_functions_f.lib;elementary_functions.lib;polynomials_f.lib;linear_algebra_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <RandomizedBaseAddress>false</RandomizedBaseAddress>
     </Link>
     <PreLinkEvent>
@@ -232,7 +229,6 @@ lib /DEF:"$(ProjectDir)linear_algebra_f_import.def" /SUBSYSTEM:WINDOWS /MACHINE:
 lib /DEF:"$(ProjectDir)polynomials_f_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)polynomials_f.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)io_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)io.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)output_stream_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)output_stream.lib" 1&gt;NUL 2&gt;NUL
-lib /DEF:"$(ProjectDir)threads_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)threads.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)console_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)sciconsole.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)dynamic_link_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)dynamic_link.lib" 1&gt;NUL 2&gt;NUL
 lib /DEF:"$(ProjectDir)fileio_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)fileio.lib" 1&gt;NUL 2&gt;NUL
@@ -255,7 +251,6 @@ lib /DEF:"$(ProjectDir)fileio_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
     <None Include="linear_algebra_f_Import.def" />
     <None Include="output_stream_Import.def" />
     <None Include="polynomials_f_Import.def" />
-    <None Include="threads_Import.def" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="includes\analysis\AnalysisVisitor.hxx" />
@@ -478,6 +473,7 @@ lib /DEF:"$(ProjectDir)fileio_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
     <ClInclude Include="includes\system_env\sci_path.h" />
     <ClInclude Include="includes\system_env\sci_tmpdir.h" />
     <ClInclude Include="includes\system_env\setenvvar.h" />
+    <ClInclude Include="includes\system_env\threadmanagement.hxx" />
     <ClInclude Include="includes\types\alltypes.hxx" />
     <ClInclude Include="includes\types\arrayof.hxx" />
     <ClInclude Include="includes\types\bool.hxx" />
@@ -593,6 +589,7 @@ lib /DEF:"$(ProjectDir)fileio_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
     <ClCompile Include="src\cpp\system_env\sci_path.cpp" />
     <ClCompile Include="src\cpp\system_env\sci_tmpdir.cpp" />
     <ClCompile Include="src\cpp\system_env\setenvvar.cpp" />
+    <ClCompile Include="src\cpp\system_env\threadmanagement.cpp" />
     <ClCompile Include="src\cpp\types\addfunction.cpp" />
     <ClCompile Include="src\cpp\types\arrayof.cpp" />
     <ClCompile Include="src\cpp\types\bool.cpp" />
@@ -645,6 +642,9 @@ lib /DEF:"$(ProjectDir)fileio_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform
     <ProjectReference Include="..\output_stream\src\c\output_stream.vcxproj">
       <Project>{a5911cd7-f8e8-440c-a23e-4843a0636f3a}</Project>
     </ProjectReference>
+    <ProjectReference Include="..\threads\threads.vcxproj">
+      <Project>{50a1ffc8-adc2-4d9e-a2d0-5dcd63188ae9}</Project>
+    </ProjectReference>
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
index b12a6ff..2a457d8 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup>
     <Library Include="..\..\bin\blasplus.lib" />
     <None Include="output_stream_Import.def">
       <Filter>Libraries Dependencies</Filter>
     </None>
-    <None Include="threads_Import.def">
-      <Filter>Libraries Dependencies</Filter>
-    </None>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="includes\exps\all.hxx">
     <ClInclude Include="includes\analysis\Temporary.hxx">
       <Filter>Header Files\analysis</Filter>
     </ClInclude>
+    <ClInclude Include="includes\system_env\threadmanagement.hxx">
+      <Filter>Header Files\system_env</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="src\cpp\ast\debugvisitor.cpp">
     <ClCompile Include="src\cpp\analysis\XBlock.cpp">
       <Filter>Source Files\ast\analysis</Filter>
     </ClCompile>
+    <ClCompile Include="src\cpp\system_env\threadmanagement.cpp">
+      <Filter>Source Files\system_env</Filter>
+    </ClCompile>
   </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
index 916e131..424586c 100644 (file)
@@ -4,4 +4,3 @@ LIBRARY    core.dll
 EXPORTS
 MyHeapFree
 MyHeapAlloc
-getAstPendingSignal
\ No newline at end of file
diff --git a/scilab/modules/ast/includes/system_env/threadmanagement.hxx b/scilab/modules/ast/includes/system_env/threadmanagement.hxx
new file mode 100644 (file)
index 0000000..435b275
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+*  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+*  Copyright (C) 2015 - Scilab-Enterprises - Cedric Delamarre
+*
+*  This file must be used under the terms of the CeCILL.
+*  This source file is licensed as described in the file COPYING, which
+*  you should have received as part of this distribution.  The terms
+*  are also available at
+*  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+
+#ifndef __THREADMANAGEMENT_HXX__
+#define __THREADMANAGEMENT_HXX__
+
+extern "C"
+{
+#include "Thread_Wrapper.h"
+#include "dynamiclibrary.h"
+#include "dynlib_ast.h"
+}
+
+class EXTERN_AST ThreadManagement
+{
+private :
+    static __threadLock m_RunnerLock;
+    static __threadLock m_StartLock;
+    static __threadLock m_ParseLock;
+    static __threadLock m_StoreCommandLock;
+
+    static __threadSignal m_ConsoleExecDone;
+    static __threadSignalLock m_ConsoleExecDoneLock;
+
+    static __threadSignal m_AwakeRunner;
+    static __threadSignalLock m_AwakeRunnerLock;
+
+    static __threadSignal m_AstPending;
+    static __threadSignalLock m_AstPendingLock;
+
+    static __threadSignal m_StartPending;
+    static __threadSignalLock m_StartPendingLock;
+
+    static __threadSignal m_CommandStored;
+    static __threadSignalLock m_CommandStoredLock;
+
+
+public :
+
+    static void initialize(void);
+
+    static void LockStart(void);
+    static void UnlockStart(void);
+    static void LockParser(void);
+    static void UnlockParser(void);
+    static void LockStoreCommand(void);
+    static void UnlockStoreCommand(void);
+    static void LockRunner(void);
+    static void UnlockRunner(void);
+
+    static void SendAstPendingSignal(void);
+    static void WaitForAstPendingSignal(void);
+    static void SendConsoleExecDoneSignal(void);
+    static void WaitForConsoleExecDoneSignal(void);
+    static void SendAwakeRunnerSignal(void);
+    static void WaitForAwakeRunnerSignal(void);
+    static void SendStartPendingSignal(void);
+    static void WaitForStartPendingSignal(void);
+    static void SendCommandStoredSignal(void);
+    static void WaitForCommandStoredSignal(void);
+
+};
+
+#endif /* !__THREADMANAGEMENT_HXX__ */
index 5f77888..dfbf823 100644 (file)
 #include "macro.hxx"
 
 #include "runner.hxx"
+#include "threadmanagement.hxx"
 
 extern "C"
 {
 #include "sciprint.h"
 #include "os_string.h"
 #include "elem_common.h"
-
-#include "Thread_Wrapper.h"
 }
 
 namespace ast
@@ -768,7 +767,7 @@ void RunVisitorT<T>::visitprivate(const SeqExp  &e)
     {
         if (pThreadMe && pThreadMe->getInterrupt())
         {
-            __Signal(getAstPendingSignal());
+            ThreadManagement::SendAstPendingSignal();
             pThreadMe->suspend();
         }
 
diff --git a/scilab/modules/ast/src/cpp/system_env/threadmanagement.cpp b/scilab/modules/ast/src/cpp/system_env/threadmanagement.cpp
new file mode 100644 (file)
index 0000000..ec71c37
--- /dev/null
@@ -0,0 +1,170 @@
+/*
+*  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2015 - Scilab Enterprises - Cedric DELAMARRE
+*
+*  This file must be used under the terms of the CeCILL.
+*  This source file is licensed as described in the file COPYING, which
+*  you should have received as part of this distribution.  The terms
+*  are also available at
+*  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+
+#include "threadmanagement.hxx"
+
+__threadLock ThreadManagement::m_StartLock;
+__threadLock ThreadManagement::m_RunnerLock;
+__threadLock ThreadManagement::m_ParseLock;
+__threadLock ThreadManagement::m_StoreCommandLock;
+
+__threadSignal ThreadManagement::m_ConsoleExecDone;
+__threadSignalLock ThreadManagement::m_ConsoleExecDoneLock;
+
+__threadSignal ThreadManagement::m_AwakeRunner;
+__threadSignalLock ThreadManagement::m_AwakeRunnerLock;
+
+__threadSignal ThreadManagement::m_AstPending;
+__threadSignalLock ThreadManagement::m_AstPendingLock;
+
+__threadSignal ThreadManagement::m_StartPending;
+__threadSignalLock ThreadManagement::m_StartPendingLock;
+
+__threadSignal ThreadManagement::m_CommandStored;
+__threadSignalLock ThreadManagement::m_CommandStoredLock;
+
+
+void ThreadManagement::initialize()
+{
+    __InitLock(&m_RunnerLock);
+    __InitLock(&m_StartLock);
+    __InitLock(&m_ParseLock);
+    __InitLock(&m_StoreCommandLock);
+
+    __InitSignal(&m_AwakeRunner);
+    __InitSignalLock(&m_AwakeRunnerLock);
+
+    __InitSignal(&m_ConsoleExecDone);
+    __InitSignalLock(&m_ConsoleExecDoneLock);
+
+    __InitSignal(&m_AstPending);
+    __InitSignalLock(&m_AstPendingLock);
+
+    __InitSignal(&m_StartPending);
+    __InitSignalLock(&m_StartPendingLock);
+
+    __InitSignal(&m_CommandStored);
+    __InitSignalLock(&m_CommandStoredLock);
+
+}
+
+void ThreadManagement::LockStart(void)
+{
+    __Lock(&m_StartLock);
+}
+
+void ThreadManagement::UnlockStart(void)
+{
+    __UnLock(&m_StartLock);
+}
+
+void ThreadManagement::LockParser(void)
+{
+    __Lock(&m_ParseLock);
+}
+
+void ThreadManagement::UnlockParser(void)
+{
+    __UnLock(&m_ParseLock);
+}
+
+void ThreadManagement::LockStoreCommand(void)
+{
+    __Lock(&m_StoreCommandLock);
+}
+
+void ThreadManagement::UnlockStoreCommand(void)
+{
+    __UnLock(&m_StoreCommandLock);
+}
+
+void ThreadManagement::LockRunner(void)
+{
+    __Lock(&m_RunnerLock);
+}
+
+void ThreadManagement::UnlockRunner(void)
+{
+    __UnLock(&m_RunnerLock);
+}
+
+void ThreadManagement::SendAstPendingSignal(void)
+{
+    __LockSignal(&m_AstPendingLock);
+    __Signal(&m_AstPending);
+    __UnLockSignal(&m_AstPendingLock);
+}
+
+void ThreadManagement::WaitForAstPendingSignal(void)
+{
+    __LockSignal(&m_AstPendingLock);
+    __Wait(&m_AstPending, &m_AstPendingLock);
+    __UnLockSignal(&m_AstPendingLock);
+}
+
+void ThreadManagement::SendConsoleExecDoneSignal(void)
+{
+    __LockSignal(&m_ConsoleExecDoneLock);
+    __Signal(&m_ConsoleExecDone);
+    __UnLockSignal(&m_ConsoleExecDoneLock);
+}
+
+void ThreadManagement::WaitForConsoleExecDoneSignal(void)
+{
+    __LockSignal(&m_ConsoleExecDoneLock);
+    __Wait(&m_ConsoleExecDone, &m_ConsoleExecDoneLock);
+    __UnLockSignal(&m_ConsoleExecDoneLock);
+}
+
+void ThreadManagement::SendAwakeRunnerSignal(void)
+{
+    __LockSignal(&m_AwakeRunnerLock);
+    __Signal(&m_AwakeRunner);
+    __UnLockSignal(&m_AwakeRunnerLock);
+}
+
+void ThreadManagement::WaitForAwakeRunnerSignal(void)
+{
+    __LockSignal(&m_AwakeRunnerLock);
+    ThreadManagement::UnlockRunner();
+    __Wait(&m_AwakeRunner, &m_AwakeRunnerLock);
+    __UnLockSignal(&m_AwakeRunnerLock);
+}
+
+void ThreadManagement::SendStartPendingSignal(void)
+{
+    __LockSignal(&m_StartPendingLock);
+    __Signal(&m_StartPending);
+    __UnLockSignal(&m_StartPendingLock);
+}
+
+void ThreadManagement::WaitForStartPendingSignal(void)
+{
+    __LockSignal(&m_StartPendingLock);
+    ThreadManagement::UnlockStart();
+    __Wait(&m_StartPending, &m_StartPendingLock);
+    __UnLockSignal(&m_StartPendingLock);
+}
+
+void ThreadManagement::SendCommandStoredSignal(void)
+{
+    __LockSignal(&m_CommandStoredLock);
+    __Signal(&m_CommandStored);
+    __UnLockSignal(&m_CommandStoredLock);
+}
+
+void ThreadManagement::WaitForCommandStoredSignal(void)
+{
+    __LockSignal(&m_CommandStoredLock);
+    __Wait(&m_CommandStored, &m_CommandStoredLock);
+    __UnLockSignal(&m_CommandStoredLock);
+}
diff --git a/scilab/modules/ast/threads_Import.def b/scilab/modules/ast/threads_Import.def
deleted file mode 100644 (file)
index 84a7738..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-LIBRARY    threads.dll
-
-
-EXPORTS
-__InitLock
-__SuspendThread
-__ResumeThread
-__GetCurrentThreadKey
-__Signal
index 3c04286..f335866 100644 (file)
@@ -65,9 +65,9 @@ static char *__CommandLine = NULL;
 
 /*--------------------------------------------------------------------------*/
 
-IMPORT_SIGNAL __threadSignal LaunchScilab;
-
-IMPORT_SIGNAL __threadSignalLock *pLaunchScilabLock;
+//IMPORT_SIGNAL __threadSignal LaunchScilab;
+//
+//IMPORT_SIGNAL __threadSignalLock *pLaunchScilabLock;
 
 static __threadSignal TimeToWork;
 
@@ -179,14 +179,14 @@ static void initAll(void)
 */
 static void *watchStoreCommand(void *in)
 {
-    __LockSignal(pLaunchScilabLock);
-    __Wait(&LaunchScilab, pLaunchScilabLock);
-    __UnLockSignal(pLaunchScilabLock);
+    //__LockSignal(pLaunchScilabLock);
+    //__Wait(&LaunchScilab, pLaunchScilabLock);
+    //__UnLockSignal(pLaunchScilabLock);
 
-    __LockSignal(pReadyForLaunch);
-    WatchStoreCmdThreadAlive = FALSE;
-    __Signal(&TimeToWork);
-    __UnLockSignal(pReadyForLaunch);
+    //__LockSignal(pReadyForLaunch);
+    //WatchStoreCmdThreadAlive = FALSE;
+    //__Signal(&TimeToWork);
+    //__UnLockSignal(pReadyForLaunch);
 
     return NULL;
 }
@@ -199,12 +199,12 @@ static void *watchStoreCommand(void *in)
 */
 static void *watchGetCommandLine(void *in)
 {
-    getCommandLine();
+    //getCommandLine();
 
-    __LockSignal(pReadyForLaunch);
-    WatchGetCmdLineThreadAlive = FALSE;
-    __Signal(&TimeToWork);
-    __UnLockSignal(pReadyForLaunch);
+    //__LockSignal(pReadyForLaunch);
+    //WatchGetCmdLineThreadAlive = FALSE;
+    //__Signal(&TimeToWork);
+    //__UnLockSignal(pReadyForLaunch);
 
     return NULL;
 }
index 8a9d8cb..ed84147 100644 (file)
@@ -2,8 +2,6 @@ LIBRARY    core.dll
 
 
 EXPORTS
-LaunchScilab
-pLaunchScilabLock
 callFunctionFromGateway
 com_
 stack_
index 2171685..1b63ba0 100644 (file)
@@ -21,8 +21,6 @@ extern "C"
 {
 #include "Thread_Wrapper.h"
 #include "dynlib_core.h"
-
-    __threadSignal* getAstPendingSignal();
 }
 
 #include "threadId.hxx"
@@ -45,8 +43,6 @@ private :
 
 public :
 
-    static void init();
-
     static void execAndWait(ast::Exp* _theProgram, ast::ExecVisitor *_visitor,
                             bool _isInterruptible, bool _isPrioritary, bool _isConsoleCommand);
 
@@ -77,25 +73,11 @@ public :
         return m_threadKey;
     }
 
-    static __threadSignal* getAstPendingSignal(void)
-    {
-        return &m_AstPending;
-    }
-
-    static __threadSignal* getConsoleExecDone(void)
-    {
-        return &m_consoleExecDone;
-    }
-
     void setThreadKey(__threadKey _threadId)
     {
         m_threadKey = _threadId;
     }
 
-    static void UnlockPrompt();
-
-    static void LockPrompt();
-
 private :
     static void *launch(void *args);
 
@@ -104,14 +86,5 @@ private :
     __threadId m_threadId;
     ast::Exp*           m_theProgram;
     ast::ExecVisitor*   m_visitor;
-
-private :
-    static __threadSignal m_consoleExecDone;
-    static __threadSignal m_awakeScilab;
-    static __threadSignalLock m_awakeScilabLock;
-    static __threadLock m_lock;
-    static __threadLock m_PrioritaryLock;
-    static __threadSignal m_AstPending;
-    static __threadSignalLock m_AstPendingLock;
 };
 #endif /* !__RUNNER_HXX__ */
index 2a149eb..38ecf70 100644 (file)
@@ -12,7 +12,8 @@
 
 #include "core_gw.hxx"
 #include "function.hxx"
-#include "runner.hxx"
+#include "threadmanagement.hxx"
+#include "configvariable.hxx"
 #include "threadId.hxx"
 #include "scilabexception.hxx"
 
@@ -36,9 +37,9 @@ types::Function::ReturnValue sci_pause(types::typed_list &in, int _iRetCount, ty
     ConfigVariable::IncreasePauseLevel();
 
     //unlock prompt thread.
-    Runner::UnlockPrompt();
+    ThreadManagement::SendAwakeRunnerSignal();
 
-    ThreadId* pThread = ConfigVariable::getLastRunningThread();
+    types::ThreadId* pThread = ConfigVariable::getLastRunningThread();
     if (pThread == NULL)
     {
         return types::Function::OK;
index 8f2fa87..c5f88a7 100644 (file)
@@ -29,6 +29,7 @@
 #include "runner.hxx"
 #include "visitor_common.hxx"
 #include "operations.hxx"
+#include "threadmanagement.hxx"
 
 extern "C"
 {
@@ -77,29 +78,10 @@ extern "C"
 
 #include "storeCommand.h"
 
-#ifdef _MSC_VER
-    __declspec(dllexport) __threadSignal        LaunchScilab = __StaticInitThreadSignal;
-    __declspec(dllexport) __threadSignalLock    *pLaunchScilabLock = NULL;
-
-#include "mmapWindows.h"
-#else
-#include <sys/mman.h>
-#ifndef MAP_ANONYMOUS
-# define MAP_ANONYMOUS MAP_ANON
-#endif
-    __threadSignal      LaunchScilab        = __StaticInitThreadSignal;
-    __threadSignalLock  *pLaunchScilabLock  = NULL;
-#endif
-
     /* Defined without include to avoid useless header dependency */
     extern BOOL isItTheDisabledLib(void);
 }
 
-__threadLock m_StartLock;
-__threadLock m_ParseLock;
-__threadSignal ExecDone;
-__threadSignalLock *pExecDoneLock;
-
 static void Add_i(void);
 static void Add_pi(void);
 static void Add_eps(void);
@@ -167,7 +149,7 @@ int StartScilabEngine(ScilabEngineInfo* _pSEI)
     fpsetmask(0);
 #endif
 
-    Runner::init();
+    ThreadManagement::initialize();
 
     checkForLinkerErrors();
 
@@ -342,10 +324,7 @@ int ExecExternalCommand(ScilabEngineInfo* _pSEI)
     if (_pSEI->pstExec)
     {
         StoreConsoleCommand(_pSEI->pstExec);
-        __LockSignal(pExecDoneLock);
-        __Wait(Runner::getConsoleExecDone(), pExecDoneLock);
-        __UnLockSignal(pExecDoneLock);
-
+        ThreadManagement::WaitForConsoleExecDoneSignal();
         return ConfigVariable::getExitStatus();
     }
 
@@ -493,7 +472,6 @@ static void processCommand(ScilabEngineInfo* _pSEI)
 // Thread used to parse and execute Scilab command setted in storeCommand
 void* scilabReadAndExecCommand(void* param)
 {
-
     int iInterruptibleCmd   = 0;
     int iPrioritaryCmd      = 0;
     int iConsoleCmd         = 0;
@@ -506,10 +484,7 @@ void* scilabReadAndExecCommand(void* param)
         if (GetCommand(&command, &iInterruptibleCmd, &iPrioritaryCmd, &iConsoleCmd) == 0)
         {
             // command queue is empty
-            __LockSignal(pLaunchScilabLock);
-            __Wait(&LaunchScilab, pLaunchScilabLock);
-            __UnLockSignal(pLaunchScilabLock);
-
+            ThreadManagement::WaitForCommandStoredSignal();
             continue;
         }
 
@@ -517,7 +492,7 @@ void* scilabReadAndExecCommand(void* param)
         _pSEI->isPrioritary = iPrioritaryCmd;
         _pSEI->isConsoleCommand = iConsoleCmd;
 
-        __Lock(&m_ParseLock);
+        ThreadManagement::LockParser();
         Parser parser;
         parser.setParseTrace(_pSEI->iParseTrace != 0);
         parseCommandTask(&parser, _pSEI->iTimed != 0, command);
@@ -525,12 +500,12 @@ void* scilabReadAndExecCommand(void* param)
         if (parser.getExitStatus() == Parser::Failed)
         {
             scilabWriteW(parser.getErrorMessage());
-            __UnLock(&m_ParseLock);
+            ThreadManagement::UnlockParser();
             continue;
         }
 
         _pSEI->pExpTree = parser.getTree();
-        __UnLock(&m_ParseLock);
+        ThreadManagement::UnlockParser();
 
         processCommand(_pSEI);
         FREE(command);
@@ -542,8 +517,8 @@ void* scilabReadAndExecCommand(void* param)
 //Thread used to parse and set console commands in storeCommand
 void* scilabReadAndStore(void* param)
 {
-    __Lock(&m_StartLock);
-    __UnLock(&m_StartLock);
+    ThreadManagement::LockStart();
+    ThreadManagement::UnlockStart();
 
     Parser::ControlStatus controlStatus = Parser::AllControlClosed;
 
@@ -559,23 +534,17 @@ void* scilabReadAndStore(void* param)
 
     if (isEmptyCommandQueue() == false)
     {
-        // unlock scilabReadAndExecCommand thread
-        __LockSignal(pExecDoneLock);
-        __Signal(&ExecDone);
-        __UnLockSignal(pExecDoneLock);
+        // unlock main thread
+        ThreadManagement::SendStartPendingSignal();
 
         // Command stored as console command by -f
         // We have to wait this execution before
         // callOnPrompt (ie: onPrompt perform a quit in test_run)
-        __LockSignal(pExecDoneLock);
-        __Wait(Runner::getConsoleExecDone(), pExecDoneLock);
-        __UnLockSignal(pExecDoneLock);
+        ThreadManagement::WaitForConsoleExecDoneSignal();
     }
 
-    // unlock scilabReadAndExecCommand thread
-    __LockSignal(pExecDoneLock);
-    __Signal(&ExecDone);
-    __UnLockSignal(pExecDoneLock);
+    // unlock main thread
+    ThreadManagement::SendStartPendingSignal();
 
     callOnPrompt();
 
@@ -629,7 +598,7 @@ void* scilabReadAndStore(void* param)
                 command = pstNewCommand;
             }
 
-            __Lock(&m_ParseLock);
+            ThreadManagement::LockParser();
             parseCommandTask(&parser, _pSEI->iTimed != 0, command);
             controlStatus = parser.getControlStatus();
             exitStatus = parser.getExitStatus();
@@ -638,7 +607,7 @@ void* scilabReadAndStore(void* param)
             {
                 delete (parser.getTree());
             }
-            __UnLock(&m_ParseLock);
+            ThreadManagement::UnlockParser();
         }
         while (controlStatus != Parser::AllControlClosed);
 
@@ -660,57 +629,16 @@ void* scilabReadAndStore(void* param)
         FREE(command);
         command = NULL;
 
-        __LockSignal(pExecDoneLock);
-        __Wait(Runner::getConsoleExecDone(), pExecDoneLock);
-        __UnLockSignal(pExecDoneLock);
+        ThreadManagement::WaitForConsoleExecDoneSignal();
 
         callOnPrompt();
     }
 
-    __Signal(&LaunchScilab);
+    // Awake scilabReadAndExecCommand thread in case of scilab exit
+    ThreadManagement::SendCommandStoredSignal();
     return NULL;
 }
 
-void ReleaseScilabSignal(__threadSignal* _Signal, __threadSignalLock* _Lock)
-{
-#ifdef _MSC_VER
-    /* http://msdn.microsoft.com/en-us/magazine/cc164040.aspx */
-    if (_Lock && (_Lock->LockCount == -1))
-#else
-    if (_Lock)
-#endif
-    {
-        __UnLockSignal(_Lock);
-        munmap(_Lock, sizeof(__threadSignalLock));
-        _Lock = NULL;
-#ifdef _MSC_VER
-        /* On Windows , we need to force value */
-        _Signal = __StaticInitThreadSignal;
-#endif
-    }
-}
-
-void InitializeScilabSignal(__threadSignal* _Signal, __threadSignalLock** _Lock, void (*func)(void))
-{
-    if (*_Lock == NULL)
-    {
-        *_Lock = (__threadSignalLock*)mmap(0, sizeof(__threadSignalLock), PROT_READ | PROT_WRITE, MAP_SHARED |  MAP_ANONYMOUS, -1, 0);
-        __InitSignal(_Signal);
-        __InitSignalLock(*_Lock);
-        atexit(func);
-    }
-}
-
-void ReleaseLaunchScilabSignal(void)
-{
-    ReleaseScilabSignal(&LaunchScilab, pLaunchScilabLock);
-}
-
-void ReleaseDoneScilabSignal(void)
-{
-    ReleaseScilabSignal(&ExecDone, pExecDoneLock);
-}
-
 /*
 ** -*- Interactive Main -*-
 */
@@ -734,23 +662,14 @@ static int interactiveMain(ScilabEngineInfo* _pSEI)
     __threadId threadIdCommand;
     __threadKey threadKeyCommand;
 
-    __InitLock(&m_StartLock);
-    __InitLock(&m_ParseLock);
-
-    InitializeScilabSignal(&LaunchScilab, &pLaunchScilabLock, ReleaseLaunchScilabSignal);
-    InitializeScilabSignal(&ExecDone, &pExecDoneLock, ReleaseDoneScilabSignal);
-
-    __Lock(&m_StartLock);
+    ThreadManagement::LockStart();
     // thread to manage console command
     __CreateThreadWithParams(&threadIdConsole, &threadKeyConsole, &scilabReadAndStore, _pSEI);
 
     // scilabReadAndStore thread must be execute before scilabReadAndExecCommand
     // to be such that the -f command stored is not removed
     // from queue before scilabReadAndStore is waiting for.
-    __LockSignal(pExecDoneLock);
-    __UnLock(&m_StartLock);
-    __Wait(&ExecDone, pExecDoneLock);
-    __UnLockSignal(pExecDoneLock);
+    ThreadManagement::WaitForStartPendingSignal();
 
     // thread to manage command stored
     __CreateThreadWithParams(&threadIdCommand, &threadKeyCommand, &scilabReadAndExecCommand, _pSEI);
index de94254..386a99e 100644 (file)
  */
 
 #include "runner.hxx"
-
-__threadLock Runner::m_lock;
-
-__threadSignal Runner::m_consoleExecDone;
-
-__threadSignal Runner::m_awakeScilab;
-__threadSignalLock Runner::m_awakeScilabLock;
-
-__threadSignal Runner::m_AstPending;
-__threadSignalLock Runner::m_AstPendingLock;
-
+#include "threadmanagement.hxx"
 
 using namespace ast;
 
-__threadSignal* getAstPendingSignal(void)
-{
-    return Runner::getAstPendingSignal();
-}
-
-__threadSignal* getConsoleExecDone(void)
-{
-    return Runner::getConsoleExecDone();
-}
-
-
-void Runner::init()
-{
-    __InitSignal(&m_awakeScilab);
-    __InitSignalLock(&m_awakeScilabLock);
-
-    __InitSignal(&m_consoleExecDone);
-
-    __InitSignal(&m_AstPending);
-    __InitSignalLock(&m_AstPendingLock);
-}
-
 void *Runner::launch(void *args)
 {
     bool bdoUnlock = false;
     //try to lock locker ( waiting parent thread register me )
-    __Lock(&m_lock);
+    ThreadManagement::LockRunner();
     //just release locker
-    __UnLock(&m_lock);
+    ThreadManagement::UnlockRunner();
 
     __threadKey currentThreadKey = __GetCurrentThreadKey();
     ThreadId* pThread = ConfigVariable::getThread(currentThreadKey);
@@ -88,12 +56,12 @@ void *Runner::launch(void *args)
         // This case appear when error is throw or when
         // non-prioritary execute this last SeqExp.
         pThread->setInterrupt(false);
-        __Signal(&Runner::m_AstPending);
+        ThreadManagement::SendAstPendingSignal();
     }
 
     if (pThread->isConsoleCommand())
     {
-        __Signal(&Runner::m_consoleExecDone);
+        ThreadManagement::SendConsoleExecDoneSignal();
     }
 
     //unregister thread
@@ -103,29 +71,12 @@ void *Runner::launch(void *args)
 
     if (bdoUnlock)
     {
-        UnlockPrompt();
+        ThreadManagement::SendAwakeRunnerSignal();
     }
 
     return NULL;
 }
 
-void Runner::LockPrompt()
-{
-    __LockSignal(&m_awakeScilabLock);
-    //free locker to release thread
-    __UnLock(&m_lock);
-    __Wait(&m_awakeScilab, &m_awakeScilabLock);
-    __UnLockSignal(&m_awakeScilabLock);
-}
-
-void Runner::UnlockPrompt()
-{
-    __LockSignal(&m_awakeScilabLock);
-    __Signal(&m_awakeScilab);
-    __UnLockSignal(&m_awakeScilabLock);
-}
-
-
 void Runner::execAndWait(ast::Exp* _theProgram, ast::ExecVisitor *_visitor,
                          bool _isPrioritaryThread, bool _isInterruptibleThread, bool _isConsoleCommand)
 {
@@ -135,10 +86,8 @@ void Runner::execAndWait(ast::Exp* _theProgram, ast::ExecVisitor *_visitor,
         __threadKey threadKey;
         __threadId threadId;
 
-        //init locker
-        __InitLock(&m_lock);
         //lock locker
-        __Lock(&m_lock);
+        ThreadManagement::LockRunner();
 
         types::ThreadId* pInterruptibleThread = ConfigVariable::getLastRunningThread();
         if (_isPrioritaryThread)
@@ -148,9 +97,7 @@ void Runner::execAndWait(ast::Exp* _theProgram, ast::ExecVisitor *_visitor,
                 if (pInterruptibleThread->isInterruptible())
                 {
                     pInterruptibleThread->setInterrupt(true);
-                    __LockSignal(&m_AstPendingLock);
-                    __Wait(&m_AstPending, &m_AstPendingLock);
-                    __UnLockSignal(&m_AstPendingLock);
+                    ThreadManagement::WaitForAstPendingSignal();
                 }
                 else
                 {
@@ -177,7 +124,7 @@ void Runner::execAndWait(ast::Exp* _theProgram, ast::ExecVisitor *_visitor,
         pThread->setInterruptible(_isInterruptibleThread);
 
         //free locker to release thread && wait and of thread execution
-        LockPrompt();
+        ThreadManagement::WaitForAwakeRunnerSignal();
 
         if (pInterruptibleThread && pInterruptibleThread->getInterrupt())
         {
index f9799c3..6fcf10c 100644 (file)
 /*--------------------------------------------------------------------------*/
 extern "C"
 {
-#define NOMINMAX
 #include "storeCommand.h"
-#include "Thread_Wrapper.h"
-
-    // mmap
-#ifdef _MSC_VER
-#include "mmapWindows.h"
-#else
-#include <sys/mman.h>
-#ifndef MAP_ANONYMOUS
-# define MAP_ANONYMOUS MAP_ANON
-#endif
-#endif
-
 }
 
 #include "parser.hxx"
@@ -35,6 +22,7 @@ extern "C"
 #include "scilabexception.hxx"
 #include "localization.hxx"
 #include "runner.hxx"
+#include "threadmanagement.hxx"
 
 using namespace ast;
 /*--------------------------------------------------------------------------*/
@@ -58,76 +46,55 @@ struct CommandRec
     CommandRec(char* command, int isInterruptible, int isPrioritary, int isConsole) : m_command(command), m_isInterruptible(isInterruptible), m_isPrioritary(isPrioritary), m_isConsole(isConsole) {}
 };
 /*--------------------------------------------------------------------------*/
-/* Extern Signal to say we git a StoreCommand. */
-extern "C"
-{
-    extern __threadSignal LaunchScilab;
-}
-/*--------------------------------------------------------------------------*/
 static std::list<CommandRec> commandQueue;
 static std::list<CommandRec> commandQueuePrioritary;
-//static __threadLock commandQueueSingleAccess = __StaticInitLock;
-static void release(void);
-static __threadLock* getCommandQueueSingleAccess()
-{
-    static __threadLock* ptr = NULL;
-    if (!ptr)
-    {
-        ptr = (__threadLock*)mmap(0, sizeof(__threadLock), PROT_READ | PROT_WRITE, MAP_SHARED |  MAP_ANONYMOUS, -1, 0);
-#ifdef _MSC_VER
-        *ptr =  __StaticInitLock;
-#else
-        __InitSignalLock(ptr);
-#endif
-        atexit(release);
-    }
-    return ptr;
-}
-
-static void release(void)
-{
-    if (getCommandQueueSingleAccess())
-    {
-        __UnLock(getCommandQueueSingleAccess());
-    }
-}
 /*--------------------------------------------------------------------------*/
 int StoreCommand(char *command)
 {
-    __Lock(getCommandQueueSingleAccess());
+    ThreadManagement::LockStoreCommand();
     commandQueue.emplace_back(os_strdup(command),
                               /*is prioritary*/ 0,
                               /* is interruptible*/ 1,
                               /* from console */ 0);
-    __UnLock(getCommandQueueSingleAccess());
-    __Signal(&LaunchScilab);
+
+    ThreadManagement::UnlockStoreCommand();
+    // Awake Scilab to execute a new command
+    ThreadManagement::SendCommandStoredSignal();
 
     return 0;
 }
 
 int StoreConsoleCommand(char *command)
 {
-    __Lock(getCommandQueueSingleAccess());
+    ThreadManagement::LockStoreCommand();
     commandQueuePrioritary.emplace_back(os_strdup(command),
                                         /*is prioritary*/ 1,
                                         /* is interruptible*/ 1,
                                         /* from console */ 1);
-    __UnLock(getCommandQueueSingleAccess());
-    __Signal(&LaunchScilab);
-    Runner::UnlockPrompt();
+
+    ThreadManagement::UnlockStoreCommand();
+    // Awake Scilab to execute a new command
+    ThreadManagement::SendCommandStoredSignal();
+    // Awake Runner to execute this prioritary command
+    ThreadManagement::SendAwakeRunnerSignal();
+
     return 0;
 }
 
 int StorePrioritaryCommand(char *command)
 {
-    __Lock(getCommandQueueSingleAccess());
+    ThreadManagement::LockStoreCommand();
     commandQueuePrioritary.emplace_back(os_strdup(command),
                                         /*is prioritary*/ 1,
                                         /* is interruptible*/ 0,
                                         /* from console */ 0);
-    __UnLock(getCommandQueueSingleAccess());
-    __Signal(&LaunchScilab);
-    Runner::UnlockPrompt();
+
+    ThreadManagement::UnlockStoreCommand();
+    // Awake Scilab to execute a new command
+    ThreadManagement::SendCommandStoredSignal();
+    // Awake Runner to execute this prioritary command
+    ThreadManagement::SendAwakeRunnerSignal();
+
     return 0;
 }
 
@@ -144,7 +111,7 @@ int GetCommand (char** cmd, int* piInterruptible, int* piPrioritary, int* piCons
 {
     int iCommandReturned = 0;
 
-    __Lock(getCommandQueueSingleAccess());
+    ThreadManagement::LockStoreCommand();
     if (commandQueuePrioritary.empty() == false)
     {
         *cmd = os_strdup(commandQueuePrioritary.front().m_command);
@@ -169,7 +136,7 @@ int GetCommand (char** cmd, int* piInterruptible, int* piPrioritary, int* piCons
 
         iCommandReturned = 1;
     }
-    __UnLock(getCommandQueueSingleAccess());
+    ThreadManagement::UnlockStoreCommand();
 
     return iCommandReturned;
 }
index 621dcf2..b0bc2ad 100644 (file)
@@ -25,6 +25,7 @@
 #include "configvariable.hxx"
 #include "types_tools.hxx"
 #include "runner.hxx"
+#include "threadmanagement.hxx"
 
 #include <iostream>
 #include <fstream>
@@ -296,7 +297,7 @@ types::Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, typ
         {
             if (pThreadMe && pThreadMe->getInterrupt())
             {
-                __Signal(getAstPendingSignal());
+                ThreadManagement::SendAstPendingSignal();
                 pThreadMe->suspend();
             }
 
index de0e615..1cc80a1 100644 (file)
@@ -24,6 +24,7 @@
 #include "configvariable.hxx"
 #include "context.hxx"
 #include "runner.hxx"
+#include "threadmanagement.hxx"
 
 #include <iostream>
 #include <fstream>
@@ -213,7 +214,7 @@ Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, types::
         {
             if (pThreadMe && pThreadMe->getInterrupt())
             {
-                __Signal(getAstPendingSignal());
+                ThreadManagement::SendAstPendingSignal();
                 pThreadMe->suspend();
             }