From: rahuel Date: Wed, 8 Dec 2004 12:58:28 +0000 (+0000) Subject: Python execution management : Lock/Unlock X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=16e5cac413d986b9a43b15fd24e406b0ce19a318;p=modules%2Fsuperv.git Python execution management : Lock/Unlock --- diff --git a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx index e044c34..363f373 100644 --- a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx +++ b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx @@ -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 ; diff --git a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx index f99c191..c6d3169 100644 --- a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx +++ b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx @@ -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 ) ;