Hello i have a problem with RWRecMutex
for example if i have the next slice definition
Code:
interface Reader
{
nonmutating double getAmount();
}
interface Writer
{
idempotent doSameThing();
}
class A implements Writer,Reader
{
double total;
dobule rest;
}
and the c++ implementation
Code:
class AI : virtual public A
{
virtual doSameThing(const Ice::Current& current);
virtual getAmount(const Ice::Current& current)const;
}
in cpp file
Code:
AI::getAmount(const Ice::Current& const)const
{
IceUtil::RWRecMutes::RLock sync(this);
return total-rest;
}
AI::doSameThing(const Ice::Current& current)
{
IceUtil::RWRecMutex::WLock sync(this);
if(getAmount()>0) //Server blocked at this point
rest++;
}
Is normal that the servers block here because i invoke a Read opeation inside a Write operation. In this example can be solved easy with chage the code of getAmount to the doSameThing but this solution don't scale well.
how can aboid this ?
thanks in adavantage