1 /*
2  *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  *  Copyright (C) 2019-2019 - ESI Group - Cedric Delamarre
4  *
5  * This file is hereby licensed under the terms of the GNU GPL v2.0,
6  * pursuant to article 5.3.4 of the CeCILL v.2.1.
7  * This file was originally licensed under the terms of the CeCILL v2.1,
8  * and continues to be available under such terms.
9  * For more information, see the COPYING file which you should have received
10  * along with this program.
11  *
12  */
13 
14 #include "configvariable.hxx"
15 #include "threadmanagement.hxx"
16 #include "runner.hxx"
17 
18 extern "C" {
19 #include "pause.h"
20 }
21 
pause(void)22 void pause(void)
23 {
24     ConfigVariable::IncreasePauseLevel();
25 
26     //return to console so change mode to 2
27     int iOldMode = ConfigVariable::getPromptMode();
28     ConfigVariable::setPromptMode(2);
29 
30     // unlock console thread to display prompt again
31     ThreadManagement::SendConsoleExecDoneSignal();
32 
33     int iPauseLevel = ConfigVariable::getPauseLevel();
34     while (ConfigVariable::getPauseLevel() == iPauseLevel)
35     {
36         ThreadManagement::SendAwakeRunnerSignal();
37         ThreadManagement::WaitForRunMeSignal();
38         if(StaticRunner::isRunnerAvailable())
39         {
40             StaticRunner::launch();
41         }
42     }
43 
44     //return from console so change mode to initial
45     ConfigVariable::setPromptMode(iOldMode);
46 }