exit( 0 ) ;
}
_ExecutePythonSync = false ;
+
+ pthread_mutex_init( &_ReturnPythonMutex , NULL ) ;
if ( pthread_cond_init( &_ReturnPythonCond , NULL ) ) {
perror("pthread_cond_init( &_ReturnPythonCond , NULL )") ;
exit( 0 ) ;
// Called by the main thread at Return from the python function ==> activation of
// a SuperVisionExecutor thread
void Engines_Container_i::ActivatePythonReturn() {
+ if ( pthread_mutex_lock( &_ReturnPythonMutex ) ) {
+ perror("ActivatePythonReturn pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
if ( _ReturnPythonSync ) {
cout << pthread_self() << "pthread_cond ActivatePythonReturn pthread_cond_signal :" << endl ;
if ( pthread_cond_signal( &_ReturnPythonCond ) ) {
cout << pthread_self() << "pthread_cond NO ActivatePythonReturn pthread_cond_signal" << endl ;
_ReturnPythonSync = true ;
}
- if ( pthread_mutex_unlock( &_ExecutePythonMutex ) ) {
+ if ( pthread_mutex_unlock( &_ReturnPythonMutex ) ) {
perror("ActivatePythonReturn pthread_mutex_unlock ") ;
exit( 0 ) ;
}
// execute Py_InitModule( InitPyRunMethod , PyMethodDef )
void Engines_Container_i::ActivatePythonExecution( char* InitPyRunMethod ,
PyMethodDef * MethodPyRunMethod ) {
- if ( pthread_mutex_lock( &_ExecutePythonMutex ) ) {
- perror("ActivatePythonExecution pthread_mutex_lock ") ;
- exit( 0 ) ;
- }
_InitPyRunMethod = InitPyRunMethod ;
_MethodPyRunMethod = MethodPyRunMethod ;
_PyString = NULL ;
// Called by a SuperVisionExecutor thread ===> activate the main thread that have to
// execute PyRun_SimpleString( thePyString )
bool Engines_Container_i::ActivatePythonExecution( char* thePyString ) {
- if ( pthread_mutex_lock( &_ExecutePythonMutex ) ) {
- perror("ActivatePythonExecution pthread_mutex_lock ") ;
- exit( 0 ) ;
- }
_InitPyRunMethod = NULL ;
_MethodPyRunMethod = NULL ;
_PyString = thePyString ;
// execute PyEval_CallObject( thePyRunMethod , ArgsList )
PyObject * Engines_Container_i::ActivatePythonExecution( PyObject * thePyRunMethod ,
PyObject * ArgsList ) {
- if ( pthread_mutex_lock( &_ExecutePythonMutex ) ) {
- perror("ActivatePythonExecution pthread_mutex_lock ") ;
- exit( 0 ) ;
- }
_InitPyRunMethod = NULL ;
_MethodPyRunMethod = NULL ;
_PyString = NULL ;
// Called by a SuperVisionExecutor thread ===> activation of the main thread
void Engines_Container_i::ActivatePythonExecution() {
+ if ( pthread_mutex_lock( &_ExecutePythonMutex ) ) {
+ perror("ActivatePythonExecution pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
if ( _ExecutePythonSync ) {
cout << pthread_self() << "pthread_cond ActivatePythonExecution pthread_cond_signal :" << endl ;
if ( pthread_cond_signal( &_ExecutePythonCond ) ) {
- perror("ActivatePythonExecution pthread_cond_broadcast ") ;
+ perror("ActivatePythonExecution pthread_cond_signal ") ;
}
cout << pthread_self() << "pthread_cond ActivatePythonExecution pthread_cond_signaled" << endl ;
}
// Called by a SuperVisionExecutor thread ===> wait for the end of python execution
void Engines_Container_i::WaitReturnPythonExecution() {
- if ( pthread_mutex_lock( &_ExecutePythonMutex ) ) {
+ if ( pthread_mutex_lock( &_ReturnPythonMutex ) ) {
perror("WaitReturnPythonExecution pthread_mutex_lock ") ;
exit( 0 ) ;
}
if ( !_ReturnPythonSync ) {
cout << pthread_self() << "pthread_cond WaitReturnPythonExecution pthread_cond_wait :" << endl ;
_ReturnPythonSync = true ;
- if ( pthread_cond_wait( &_ReturnPythonCond , &_ExecutePythonMutex ) ) {
+ if ( pthread_cond_wait( &_ReturnPythonCond , &_ReturnPythonMutex ) ) {
perror("WaitReturnPythonExecution pthread_cond_wait ") ;
}
cout << pthread_self() << "pthread_cond WaitReturnPythonExecution pthread_cond_waited" << endl ;
cout << pthread_self() << "pthread_cond NO WaitReturnPythonExecution pthread_cond_wait" << endl ;
}
_ReturnPythonSync = false ;
- if ( pthread_mutex_unlock( &_ExecutePythonMutex ) ) {
+ if ( pthread_mutex_unlock( &_ReturnPythonMutex ) ) {
perror("WaitReturnPythonExecution pthread_mutex_unlock ") ;
exit( 0 ) ;
}