|
Boost Users : |
Subject: [Boost-users] [threads] Deadlock?
From: The Novice Coder (boost_at_[hidden])
Date: 2011-03-28 18:05:55
I'm working with boost:threads, and am having what appears to be a
deadlock issue. I'm not sure if the lock is something I'm doing, or if
it's my lack of understanding of boost::condition_variable.
The code deadlocks on this snippit:
if( wait)
{
// lock the condition, add the event, wait for the condition, and
get the return value!
boost::mutex::scoped_lock lk(serviceMutex_);
clearException();
returnValue_ = 0;
qApp->postEvent(temp_this, temp_event, Qt::HighEventPriority);
serviceCondition_.wait(lk);
}
Where wait is specified by the caller to wait for the other thread to
return. In the service request thread has this snippet:
{
boost::mutex::scoped_lock lk( serviceMutex_);
returnValue_ = qtService(s->getCommand());
serviceCondition_.notify_one();
}
I tried it with and without the lock (in the 2nd snippet) but the 2nd
snippet code is never getting called and just seems to vanish when wait
is specified. When wait isn't specified, it all works. (Non-wait is
just the same thing without any of the locks/conditions.)
Any thoughts on where to look to proceed or what documents to read ?
Thanks, and apologies for the inexperience. New to boost..
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net