From 6019fb8d9e42aafb544b66fea8326f5d36f378c0 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Thu, 9 Mar 2017 15:06:41 +0100 Subject: [PATCH] First try --- idl/SALOME_SDS.idl | 1 + src/SALOMESDS/SALOMESDS_DataScopeServer.cxx | 17 +++++++++++++++++ src/SALOMESDS/SALOMESDS_DataScopeServer.hxx | 1 + src/SALOMESDS/SALOMESDS_KeyWaiter.cxx | 13 +++++++++++++ src/SALOMESDS/SALOMESDS_KeyWaiter.hxx | 1 + 5 files changed, 33 insertions(+) diff --git a/idl/SALOME_SDS.idl b/idl/SALOME_SDS.idl index c5d7e288d..24a707899 100644 --- a/idl/SALOME_SDS.idl +++ b/idl/SALOME_SDS.idl @@ -130,6 +130,7 @@ module SALOME KeyWaiter waitForKeyInVarAndKillIt(in string varName, in ByteVec keyVal, out Transaction transac) raises (SALOME::SALOME_Exception); void atomicApply(in ListOfTransaction transactions) raises (SALOME::SALOME_Exception); ByteVec waitForMonoThrRev(in KeyWaiter kw) raises (SALOME::SALOME_Exception); + ByteVec waitForAndKill(in KeyWaiter kw) raises (SALOME::SALOME_Exception); }; interface DataServerManager diff --git a/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx b/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx index 92dae7794..ac4772586 100644 --- a/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx +++ b/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx @@ -771,6 +771,23 @@ SALOME::ByteVec *DataScopeServerTransaction::waitForMonoThrRev(SALOME::KeyWaiter return zeRet; } +SALOME::ByteVec *DataScopeServerTransaction::waitForAndKill(SALOME::KeyWaiter_ptr kw) +{ + PortableServer::ServantBase *ret(0); + try + { + ret=_poa_for_key_waiter->reference_to_servant(kw);// Warning ref cnt of ret has been incremented ! + } + catch(...) { ret=0; } + KeyWaiter *retc(dynamic_cast(ret)); + if(!retc) + throw Exception("DataScopeServerTransaction::invokeMonoThr : internal error 1 !"); + retc->_remove_ref();// restore the counter afer _poa_for_key_waiter->reference_to_servant(kw) + SALOME::ByteVec *zeRet(retc->waitForAndKill()); + retc->enforcedRelease(); + return zeRet; +} + void DataScopeServerTransaction::atomicApply(const SALOME::ListOfTransaction& transactions) { std::size_t sz(transactions.length()); diff --git a/src/SALOMESDS/SALOMESDS_DataScopeServer.hxx b/src/SALOMESDS/SALOMESDS_DataScopeServer.hxx index 8f1e87e04..c814dd3ec 100644 --- a/src/SALOMESDS/SALOMESDS_DataScopeServer.hxx +++ b/src/SALOMESDS/SALOMESDS_DataScopeServer.hxx @@ -129,6 +129,7 @@ namespace SALOMESDS void pingKey(PyObject *keyObj); void notifyKey(const std::string& varName, PyObject *keyObj, PyObject *valueObj); SALOME::ByteVec *waitForMonoThrRev(SALOME::KeyWaiter_ptr kw); + SALOME::ByteVec *waitForAndKill(SALOME::KeyWaiter_ptr kw); public://remotely callable char *getAccessOfVar(const char *varName); void fetchAndGetAccessOfVar(const char *varName, CORBA::String_out access, SALOME::ByteVec_out data); diff --git a/src/SALOMESDS/SALOMESDS_KeyWaiter.cxx b/src/SALOMESDS/SALOMESDS_KeyWaiter.cxx index ca951bcda..076aec745 100644 --- a/src/SALOMESDS/SALOMESDS_KeyWaiter.cxx +++ b/src/SALOMESDS/SALOMESDS_KeyWaiter.cxx @@ -97,6 +97,19 @@ SALOME::ByteVec *KeyWaiter::waitForMonoThr() return PickelizedPyObjServer::FromCppToByteSeq(st); } +SALOME::ByteVec *KeyWaiter::waitForAndKill() +{ + if(!_ze_value) + throw Exception("KeyWaiter::waitForAndKill : no value ! invalid call of this method !"); + Py_XINCREF(_ze_value); + std::string st(PickelizedPyObjServer::Pickelize(_ze_value,_var->getFather())); + // + if(PyDict_DelItem(_var->getPyObj(),_ze_key)!=0) + throw Exception("KeyWaiter::waitForAndKill : error during entry removal !"); + // + return PickelizedPyObjServer::FromCppToByteSeq(st); +} + /*! * WARNING call this method before calling go ! */ diff --git a/src/SALOMESDS/SALOMESDS_KeyWaiter.hxx b/src/SALOMESDS/SALOMESDS_KeyWaiter.hxx index 7f3eee1b0..521ce705a 100644 --- a/src/SALOMESDS/SALOMESDS_KeyWaiter.hxx +++ b/src/SALOMESDS/SALOMESDS_KeyWaiter.hxx @@ -49,6 +49,7 @@ namespace SALOMESDS void go(); std::string getVarName() const { return _var->getVarNameCpp(); } SALOME::ByteVec *waitForMonoThr(); + SALOME::ByteVec *waitForAndKill(); private: DataScopeServerTransaction *getDSS() const { return static_cast(_var->getFather()); }//thanks to dynamic_cast in constructor private: -- 2.39.2