* 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()
+void KeyWaiter::waitFor()
{
sem_wait(&_sem);
if(!_ze_value)
throw Exception("KeyWaiter::waitFor : internal error 1 !");
- SALOME::ByteVec *ret(0);
- {// 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));
- 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;
}
/*!
#
self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'ab':[4,5,6],'cd':[7,8,9,10]})
wk=dss.waitForKeyInVar(varName,obj2Str("cd"))
- self.assertEqual(str2Obj(wk.waitFor()),[7,8,9,10])
+ wk.waitFor()
+ self.assertEqual(str2Obj(dss.waitForMonoThrRev(wk)),[7,8,9,10])
#
nbProc=8
pool=mp.Pool(processes=nbProc)
#
self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'ab':[4,5,6],'cd':[7,8,9,10]})
wk=dss.waitForKeyInVar(varName,obj2Str("cd"))
- self.assertEqual(str2Obj(wk.waitFor()),[7,8,9,10])
+ wk.waitFor()
+ self.assertEqual(str2Obj(dss.waitForMonoThrRev(wk)),[7,8,9,10])
def testTransaction3(self):
scopeName="Scope1"
self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'ab':[4,5,6],'cd':[7,8,9,10]})
wk,t2=dss.waitForKeyInVarAndKillIt(varName,obj2Str("cd"))
self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'ab':[4,5,6],'cd':[7,8,9,10]})
- self.assertEqual(str2Obj(wk.waitFor()),[7,8,9,10])
+ wk.waitFor()
+ self.assertEqual(str2Obj(dss.waitForMonoThrRev(wk)),[7,8,9,10])
dss.atomicApply([t2])
self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'ab':[4,5,6]})
self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'ab':[4,5,6]})
wk=dss.waitForKeyInVar(varName,obj2Str("cd"))
t1.addKeyValueInVarErrorIfAlreadyExistingNow(obj2Str("cd"),obj2Str([7,8,9,10]))
- self.assertEqual(str2Obj(wk.waitFor()),[7,8,9,10])
+ wk.waitFor()
+ self.assertEqual(str2Obj(dss.waitForMonoThrRev(wk)),[7,8,9,10])
self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'ab':[4,5,6]})# it is not a bug ! commit of t1 not done !
dss.atomicApply([t1])
self.assertEqual(dss.getAccessOfVar(varName),"RdExt")
#
self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'ab':[4,5,6],'cd':[7,8,9,10]})
wk=dss.waitForKeyInVar(varName,obj2Str("cd"))
- self.assertEqual(str2Obj(wk.waitFor()),[7,8,9,10])
+ wk.waitFor()
+ self.assertEqual(str2Obj(dss.waitForMonoThrRev(wk)),[7,8,9,10])
keys=[str2Obj(elt) for elt in dss.getAllKeysOfVarWithTypeDict(varName)]
self.assertEqual(keys,['ab','cd'])