Home Help Center

A call queue question.

OrNotOrNot Member Bin.LiOrganization: GE HealthcareProject: Enterprise solution
Hi, There,
Here the code snippet from Mathews article in Issue 12.

void
CallQueue::run()
{
while(true)
{
CallPtr req;
{
Lock sync(*this);
while(!_destroy && _req.empty())
{
wait();
}
if(_destroy)
{
break;
}
req = _req.front();
_req.pop_front();
}
req->execute();
}
}


My question is why to check the _destroy again after wait() return.

I know here is some kind of trick and I remember ICE guys once mentioned this somewhere, but I can not find the actual words on it right now.


Thanks in advance.
OrNot

Comments

  • OrNotOrNot Member Bin.LiOrganization: GE HealthcareProject: Enterprise solution
    Sorry, I have to answer my stupid question on my own.

    The reason to check the _destroy again is to distinguish it from the _req.empty() since the "&&" is there.


    My mind must be deadlocked just now. :(
Sign In or Register to comment.