TclTodo from parallel thread

This commit is contained in:
Joachim Schoeberl 2015-06-26 16:30:27 +02:00
parent b31479b177
commit 085cd6c774
5 changed files with 23 additions and 1 deletions

View File

@ -326,6 +326,8 @@ extern "C" {
// redraw
DLL_HEADER void Ng_Redraw(bool blocking = false);
///
DLL_HEADER void Ng_TclCmd(string cmd);
///
DLL_HEADER void Ng_SetMouseEventHandler (netgen::MouseEventHandler * handler);
///
DLL_HEADER void Ng_SetUserVisualizationObject (netgen::UserVisualizationObject * vis);

View File

@ -2359,3 +2359,13 @@ void LinkFunction ()
{
Ng_Redraw();
}
void Ng_TclCmd(string cmd)
{
#pragma omp critical(tcltodo)
{
*(multithread.tcl_todo) += cmd;
}
}

View File

@ -41,6 +41,7 @@ namespace netgen
double percent;
const char * task;
bool demorunning;
string * tcl_todo = new string(""); // tcl commands set from parallel thread
multithreadt();
};

View File

@ -115,7 +115,7 @@ namespace netgen
extern DLL_HEADER void Render(bool blocking);
DLL_HEADER void Render (bool blocking)
{
if (blocking)
if (blocking && multithread.running)
{
multithread.redraw = 2;
while (multithread.redraw == 2) ;

View File

@ -705,6 +705,15 @@ namespace netgen
strcat (lstring, " 0");
Tcl_SetVar (interp, "::status_tetqualclasses", lstring, 0);
#pragma omp critical(tcltodo)
{
if (multithread.tcl_todo->length())
{
Tcl_Eval (interp, multithread.tcl_todo->c_str());
*multithread.tcl_todo = "";
}
}
return TCL_OK;
}