std::string fullScopeName(SALOMESDS::DataServerManager::CreateAbsNameInNSFromScopeName(_name));
SALOME_NamingService ns(_orb);
ns.Register(ptr,fullScopeName.c_str());
- _ptr_of_this=SALOME::DataScopeServerBase::_duplicate(ptr);
}
std::string DataScopeServerBase::BuildTmpVarNameFrom(const std::string& varName)
PyObject *getPickler() const { return _pickler; }
PortableServer::POA_var getPOA() const { return _poa; }
CORBA::ORB_var getORB() { return _orb; }
- //! MTA = Mono thread activated
- SALOME::DataScopeServerBase_var getObjectRefMTA() { return _ptr_of_this ;}
std::string getScopeNameCpp() const { return _name; }
static std::string BuildTmpVarNameFrom(const std::string& varName);
public:
CORBA::ORB_var _orb;
std::string _name;
std::list< std::pair< SALOME::BasicDataServer_var, BasicDataServer * > > _vars;
- // CORBA pointer of this activated by monothread POA _poa.
- SALOME::DataScopeServerBase_var _ptr_of_this;
static std::size_t COUNTER;
};
return getDSS()->getPOA4KeyWaiter();
}
+/*!
+ * WARNING : here it is the single method that can be invoked in non SINGLE_THREAD POA.
+ * So take care to do avoid collapses (especially in python).
+ */
SALOME::ByteVec *KeyWaiter::waitFor()
{
sem_wait(&_sem);
if(!_ze_value)
throw Exception("KeyWaiter::waitFor : internal error 1 !");
SALOME::ByteVec *ret(0);
- {
- SALOME::DataScopeServerBase_var ptr(_var->getFather()->getObjectRefMTA());
- SALOME::DataScopeServerTransaction_var ptr2(SALOME::DataScopeServerTransaction::_narrow(ptr));
- if(CORBA::is_nil(ptr2))
+ {// this section is to guarantee that no concurrent threads are doing python stuff at the same time
+ // Here a pickelization is needed so to guarantee to be alone doing python action the idea is to invoke using monothread POA.
+ DataScopeServerTransaction *dss(getDSS());
+ PortableServer::POA_var poa(dss->getPOA());
+ CORBA::Object_var dssPtr(poa->servant_to_reference(dss));
+ SALOME::DataScopeServerTransaction_var dssPtr2(SALOME::DataScopeServerTransaction::_narrow(dssPtr));
+ if(CORBA::is_nil(dssPtr2))
throw Exception("KeyWaiter::waitFor : internal error 2 !");
CORBA::Object_var thisPtr(getPOA()->servant_to_reference(this));
SALOME::KeyWaiter_var thisPtr2(SALOME::KeyWaiter::_narrow(thisPtr));
- ret=ptr2->waitForMonoThrRev(thisPtr2);
+ if(CORBA::is_nil(thisPtr2))
+ throw Exception("KeyWaiter::waitFor : internal error 3 !");
+ ret=dssPtr2->waitForMonoThrRev(thisPtr2);//<- this invokation through SINGLE_THREAD POA here will guarantee thread safety
}
enforcedRelease();
return ret;
}
+/*!
+ * this method is supposed to be performed in alone.
+ */
SALOME::ByteVec *KeyWaiter::waitForMonoThr()
{
+ if(!_ze_value)
+ throw Exception("KeyWaiter::waitForMonoThr : no value ! invalid call of this method !");
Py_XINCREF(_ze_value);
std::string st(PickelizedPyObjServer::Pickelize(_ze_value,_var->getFather()));
return PickelizedPyObjServer::FromCppToByteSeq(st);