panfidalgo
May 29th, 2007, 03:56 AM
hi,
the question: a boost::condition object inside two boost:scoped_lock "release" this two scoped_lock or only (as it is written in its docu):
"Releases the lock on the mutex object associated with lock, blocks the current thread of execution until readied by a call to this->notify_one() or this->notify_all(), and then reacquires the lock."
http://www.boost.org/doc/html/boost/condition.html#id1280368-bb
and the others scoped_lock are not release. For example in the next code (ignore the conts_cast, it is used because the volatile flag) :
template<typename _Tp> void foo(
){
....
boost::recursive_mutex::scoped_lock scoped_lock1(
*(const_cast<boost::recursive_mutex*> (&previous->_lock))
);{
.....
boost::recursive_mutex::scoped_lock scoped_lock2(
*(const_cast<boost::recursive_mutex*> (&_Last_returned->_lock))
);{
....
try {
boost::recursive_mutex::scoped_lock lk(
*(const_cast<boost::recursive_mutex*> (&_other_lock))
);{
(const_cast<boost::condition*>(&_Last_returned->_condition))->wait(lk);
}
} catch( boost::lock_error e ){
std::cout<<e.what()<<std::endl;
}
....
} // end _Last_returned
} // end previous
....
} // end foo
Maybe I must change the wait and do something like:
try{
(const_cast<boost::condition*>(&_Last_returned->_condition))->wait(scoped_lock2);
} catch( boost::lock_error e ){
std::cout<<e.what()<<std::endl;
}
but then I must do as wait() operations as external scoped_lock I have used. (Two wait()s in this case).
For more information, using ZThreads (like the underlying thread library)
but don't use Guards (-fpermissive flag is really ugly) I must do the 2 explicit release before the wait and after it 2 acquire and all works properly.
any idea, or any page with good information? because the official documentation is really poor:
http://www.boost.org/doc/html/boost/condition.html
or
http://www-eleves-isia.cma.fr/documentation/BoostDoc/boost_1_29_0/libs/thread/doc/condition.html#class-condition
the question: a boost::condition object inside two boost:scoped_lock "release" this two scoped_lock or only (as it is written in its docu):
"Releases the lock on the mutex object associated with lock, blocks the current thread of execution until readied by a call to this->notify_one() or this->notify_all(), and then reacquires the lock."
http://www.boost.org/doc/html/boost/condition.html#id1280368-bb
and the others scoped_lock are not release. For example in the next code (ignore the conts_cast, it is used because the volatile flag) :
template<typename _Tp> void foo(
){
....
boost::recursive_mutex::scoped_lock scoped_lock1(
*(const_cast<boost::recursive_mutex*> (&previous->_lock))
);{
.....
boost::recursive_mutex::scoped_lock scoped_lock2(
*(const_cast<boost::recursive_mutex*> (&_Last_returned->_lock))
);{
....
try {
boost::recursive_mutex::scoped_lock lk(
*(const_cast<boost::recursive_mutex*> (&_other_lock))
);{
(const_cast<boost::condition*>(&_Last_returned->_condition))->wait(lk);
}
} catch( boost::lock_error e ){
std::cout<<e.what()<<std::endl;
}
....
} // end _Last_returned
} // end previous
....
} // end foo
Maybe I must change the wait and do something like:
try{
(const_cast<boost::condition*>(&_Last_returned->_condition))->wait(scoped_lock2);
} catch( boost::lock_error e ){
std::cout<<e.what()<<std::endl;
}
but then I must do as wait() operations as external scoped_lock I have used. (Two wait()s in this case).
For more information, using ZThreads (like the underlying thread library)
but don't use Guards (-fpermissive flag is really ugly) I must do the 2 explicit release before the wait and after it 2 acquire and all works properly.
any idea, or any page with good information? because the official documentation is really poor:
http://www.boost.org/doc/html/boost/condition.html
or
http://www-eleves-isia.cma.fr/documentation/BoostDoc/boost_1_29_0/libs/thread/doc/condition.html#class-condition