Salome HOME
Python execution management : Lock/Unlock
authorrahuel <rahuel@opencascade.com>
Wed, 8 Dec 2004 12:58:28 +0000 (12:58 +0000)
committerrahuel <rahuel@opencascade.com>
Wed, 8 Dec 2004 12:58:28 +0000 (12:58 +0000)
src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx
src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx

index e044c34bc0b21591a4c36c1ce45ba8f77803c301..363f373184e48cdfaee64d39158912b31e2ae0d9 100644 (file)
@@ -456,6 +456,7 @@ GraphExecutor::FiniteStateMachine::FiniteStateMachine() {
   }
 
   pthread_mutex_init( &_MutexPythonWait , NULL ) ;
+  _MutexPythonLocked = false ;
   _ExecNumber = 0 ;
   _GraphExecutingNumber = 0 ;
   _PyInitModule = false ;
@@ -511,6 +512,10 @@ void GraphExecutor::FiniteStateMachine::Executed() {
   return ;
 }
 
+void GraphExecutor::FiniteStateMachine::PyInitModule( bool aPyInitModule ) {
+  _PyInitModule = aPyInitModule ;
+}
+
 bool GraphExecutor::FiniteStateMachine::PyInitModule() {
   bool InitedModule = _PyInitModule ;
   _PyInitModule = true ;
@@ -523,6 +528,7 @@ void GraphExecutor::FiniteStateMachine::PyLock() {
     perror( "GraphExecutor::FiniteStateMachine::PyLock" ) ;
     exit( 0 ) ;
   }
+  _MutexPythonLocked = true ;
 //  cout << pthread_self() << " GraphExecutor::FiniteStateMachine::PyLocked " << &_MutexPythonWait << endl ;
 }
 
@@ -532,9 +538,16 @@ void GraphExecutor::FiniteStateMachine::PyUnLock() {
     perror( "GraphExecutor::FiniteStateMachine::PyUnLock" ) ;
     exit( 0 ) ;
   }
+  _MutexPythonLocked = false ;
 //  cout << pthread_self() << " GraphExecutor::FiniteStateMachine::PyUnLocked " << &_MutexPythonWait << endl ;
 }
 
+void GraphExecutor::FiniteStateMachine::PyLockReset() {
+  if ( _MutexPythonLocked ) {
+    PyUnLock() ;
+  }
+}
+
 PyObject * GraphExecutor::FiniteStateMachine::PyFunction( const char * aPyFuncName ) {
   
   PyObject * RetVal = NULL ;
index f99c1914eef181fe93c073fad6d5b784551249f6..c6d316992ac6149b3a5af8c31dabf005d600f65a 100644 (file)
@@ -156,6 +156,7 @@ namespace GraphExecutor {
                                                   [ GraphExecutor::NumberOfEvents ] ;
 
       pthread_mutex_t            _MutexPythonWait ;
+      bool                       _MutexPythonLocked ;
       map< string , PyObject * > _MapOfPyFunctions ;
       bool                       _PyInitModule ;
       int                        _ExecNumber ;
@@ -180,9 +181,11 @@ namespace GraphExecutor {
 
       int ExecNumber() ;
       void Executed() ;
+      void PyInitModule(bool) ;
       bool PyInitModule() ;
       void PyLock() ;
       void PyUnLock() ;
+      void PyLockReset() ;
       bool PyFunction( const char * aPyFuncName , PyObject * aPyFunction ) ;
       PyObject * PyFunction( const char * aPyFuncName ) ;