From 72c7b1b08cc6c3352b67fa212fdbb95e35c3ed27 Mon Sep 17 00:00:00 2001 From: rahuel Date: Wed, 8 Dec 2004 12:26:08 +0000 Subject: [PATCH] New methods (and fileds) that allow the execution of python functions from the SuperVisionEngine in the main thread. It is because of Python that allow signal handling only in the main thread. --- src/Container/SALOME_Container_i.hxx | 38 +++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index 6f309c50c..5a766a220 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -41,6 +41,8 @@ #include #include +#include + class SALOME_NamingService; class Engines_Container_i: public virtual POA_Engines::Container, @@ -78,6 +80,21 @@ public: char* getHostName(); CORBA::Long getPID(); +// Execution of python functions in the main thread + pthread_t Engines_Container_i::MainThreadId() ; + void WaitPythonFunction() ; + void WaitActivatePythonExecution() ; + void ActivatePythonReturn() ; + +// Ask for execution of python functions in the main thread from SuperVisionEngine + void ActivatePythonExecution( char* InitPyRunMethod , + PyMethodDef * MethodPyRunMethod ) ; + bool ActivatePythonExecution( char* thePyString ) ; + PyObject * ActivatePythonExecution( PyObject * thePyRunMethod , + PyObject * ArgsList ) ; + void ActivatePythonExecution() ; + void WaitReturnPythonExecution() ; + protected: SALOME_NamingService *_NS ; @@ -93,9 +110,24 @@ protected: //private: - int _argc ; - char** _argv ; - long _pid; + int _argc ; + char ** _argv ; + long _pid ; + + pthread_t _MainThreadId ; + pthread_mutex_t _ExecutePythonMutex ; + pthread_cond_t _ExecutePythonCond ; + bool _ExecutePythonSync ; + + char * _InitPyRunMethod ; + PyMethodDef * _MethodPyRunMethod ; + char * _PyString ; + PyObject * _PyRunMethod ; + PyObject * _ArgsList ; + pthread_cond_t _ReturnPythonCond ; + bool _ReturnPythonSync ; + bool _ReturnValue ; + PyObject * _Result ; }; -- 2.39.2