Skip to content
Snippets Groups Projects
Commit 30aa937a authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

small modification to make the solver interface not block the GUI when the
solver runs without printing messages
parent b13756a9
No related branches found
No related tags found
No related merge requests found
// $Id: Solvers.cpp,v 1.32 2005-01-13 23:39:10 geuzaine Exp $ // $Id: Solvers.cpp,v 1.33 2005-01-14 01:40:49 geuzaine Exp $
// //
// Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
// //
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/poll.h>
#include <sys/un.h> #include <sys/un.h>
#include <unistd.h> #include <unistd.h>
...@@ -118,10 +119,39 @@ int Solver(int num, char *args) ...@@ -118,10 +119,39 @@ int Solver(int num, char *args)
SINFO[num].nbval[i] = 0; SINFO[num].nbval[i] = 0;
SINFO[num].pid = 0; SINFO[num].pid = 0;
struct pollfd pfd;
pfd.fd = sock;
pfd.events = POLLIN|POLLPRI;
while(1) {
// poll the socket file descriptor every 10 milliseconds until
// data is avalable; when nothing is available, just tend to
// pending GUI events. (This is much easier to manage than
// non-blocking IO. The real solution is of course to use threads,
// but that's still a bit of a nightmare to maintain in a portable
// way on all the platforms.)
while(1){ while(1){
if(SINFO[num].pid < 0) if(SINFO[num].pid < 0){ // process has been killed
stop = 1;
break;
}
int ret = poll(&pfd, 1, 10);
if(ret == 0){ // nothing available
WID->check();
}
else if(ret > 0){ // data is there
break;
}
else{ // error
stop = 1;
break; break;
Gmsh_ReceiveString(sock, &type, str); }
}
if(stop)
break;
if(Gmsh_ReceiveString(sock, &type, str)){
switch (type) { switch (type) {
case GMSH_CLIENT_START: case GMSH_CLIENT_START:
SINFO[num].pid = atoi(str); SINFO[num].pid = atoi(str);
...@@ -163,7 +193,9 @@ int Solver(int num, char *args) ...@@ -163,7 +193,9 @@ int Solver(int num, char *args)
Msg(SOLVER, "%-8.8s: %s", SINFO[num].name, str); Msg(SOLVER, "%-8.8s: %s", SINFO[num].name, str);
break; break;
} }
WID->check(); // update the GUI WID->check();
}
if(stop) if(stop)
break; break;
} }
......
$Id: VERSIONS,v 1.301 2005-01-13 05:45:45 geuzaine Exp $ $Id: VERSIONS,v 1.302 2005-01-14 01:40:49 geuzaine Exp $
New since 1.58: added support for discrete (triangulated) surfaces, New since 1.58: added support for discrete (triangulated) surfaces,
either in STL format or with the new "Discrete Surface" command; added either in STL format or with the new "Discrete Surface" command; added
...@@ -9,7 +9,9 @@ view data (based on the same or on a different mesh); generalized ...@@ -9,7 +9,9 @@ view data (based on the same or on a different mesh); generalized
Plugin(CutGrid); new plugins (Eigenvalues, Gradient, Curl, Plugin(CutGrid); new plugins (Eigenvalues, Gradient, Curl,
Divergence); changed default colormap to match Matlab's "Jet" Divergence); changed default colormap to match Matlab's "Jet"
colormap; new transformation matrix option for views (for colormap; new transformation matrix option for views (for
non-destructive rotations, symmetries, etc.); fixed small bugs. non-destructive rotations, symmetries, etc.); improved solver
interface to keep the GUI responsive during solver calls; the fixed
small bugs.
New in 1.58: fixed UNIX socket interface on Windows (broken by the TCP New in 1.58: fixed UNIX socket interface on Windows (broken by the TCP
solver patch in 1.57); bumped version number of default solver patch in 1.57); bumped version number of default
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment