]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
mutex on StudyBuilder
authorPaul RASCLE <paul.rascle@edf.fr>
Thu, 8 Feb 2018 07:00:43 +0000 (08:00 +0100)
committerPaul RASCLE <paul.rascle@edf.fr>
Fri, 16 Feb 2018 14:14:40 +0000 (15:14 +0100)
src/SALOMEDS/SALOMEDS_Study.cxx
src/SALOMEDS/SALOMEDS_StudyBuilder.cxx
src/SALOMEDS/SALOMEDS_StudyBuilder.hxx

index 63d44b5ac2acb37fbfc6279e84fbeeea2295e5b9..50d658b7d969fc876e8513f8d1832d2acfff069b 100644 (file)
@@ -68,6 +68,9 @@ SALOMEDS_Study::SALOMEDS_Study(SALOMEDSImpl_Study* theStudy)
   _isLocal = true;
   _local_impl = theStudy;
   _corba_impl = SALOMEDS::Study::_nil();
+
+  pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 );
+
   init_orb();
 }
 
@@ -79,6 +82,8 @@ SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy)
   long pid =  (long)getpid();
 #endif  
 
+  pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 );
+
   long addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal);
   if(_isLocal) {
     _local_impl = reinterpret_cast<SALOMEDSImpl_Study*>(addr);
index f23777af12fda26bbf3ff4aff6cd8f2c73e7e522..8aeed232c52603500333f282389a497cf63501e2 100644 (file)
@@ -50,6 +50,8 @@
 #include "Utils_ORB_INIT.hxx" 
 #include "Utils_SINGLETON.hxx" 
 
+pthread_mutex_t SALOMEDS_StudyBuilder::_remoteBuilderMutex;
+
 SALOMEDS_StudyBuilder::SALOMEDS_StudyBuilder(SALOMEDSImpl_StudyBuilder* theBuilder)
 {
   _isLocal = true;
@@ -61,6 +63,7 @@ SALOMEDS_StudyBuilder::SALOMEDS_StudyBuilder(SALOMEDSImpl_StudyBuilder* theBuild
 
 SALOMEDS_StudyBuilder::SALOMEDS_StudyBuilder(SALOMEDS::StudyBuilder_ptr theBuilder)
 {
+  pthread_mutex_lock( &_remoteBuilderMutex );
   _isLocal = false;
   _local_impl = NULL;
   _corba_impl = SALOMEDS::StudyBuilder::_duplicate(theBuilder);
@@ -70,6 +73,7 @@ SALOMEDS_StudyBuilder::SALOMEDS_StudyBuilder(SALOMEDS::StudyBuilder_ptr theBuild
 
 SALOMEDS_StudyBuilder::~SALOMEDS_StudyBuilder() 
 {
+  if (!_isLocal) pthread_mutex_unlock( &_remoteBuilderMutex );
 }
 
 _PTR(SComponent) SALOMEDS_StudyBuilder::NewComponent(const std::string& ComponentDataType)
index b7e3a616078aa80fe7f3c4ef84a0170720a737a7..37336327f261f75f283475ba2a2ff75d12713e13 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "SALOMEDSClient.hxx"
 #include "SALOMEDSImpl_StudyBuilder.hxx"
+#include <pthread.h>
 
 // IDL headers
 #include <SALOMEconfig.h>
@@ -44,7 +45,9 @@ private:
   SALOMEDS::StudyBuilder_var        _corba_impl;
   CORBA::ORB_var                    _orb;
 
+
 public:
+  static pthread_mutex_t            _remoteBuilderMutex;
 
   SALOMEDS_StudyBuilder(SALOMEDSImpl_StudyBuilder* theBuilder);
   SALOMEDS_StudyBuilder(SALOMEDS::StudyBuilder_ptr theBuilder);