|
Boost Users : |
From: Adam M (boost_at_[hidden])
Date: 2005-11-04 12:36:44
Hi,
I have a couple questions regarding boost::condition.
You can view the condition.hpp here:
http://www.boost.org/boost/thread/condition.hpp
1) wait() starts out as follows:
--------------------------------
void wait(L& lock)
{
if (!lock)
throw lock_error();
...
--------------------------------
This "if (!lock)" seems to be checking if the lock is NULL, not if the
mutex is actually locked.
In the documentation, it says:
"Throws: lock_error if !lock.locked()"
However, even this seems to be a bit dubious, because that checks to see
if the given lock is the one that locked the mutex, and *not* if the
mutex itself is locked.
Remember that the scoped_lock constructor can take a second parameter to
indicate whether or not to actually lock the mutex. One might use this
as an alternative to recursive locking, so that a synchronized function
may call another synchronized function and indicate with a flag that the
scoped_lock "initially_locked" parameter should be 'false'. If that
function then called to wait(), lock.locked() would return 'false', when
the mutex is in fact actually locked. Am I wrong?
2) In the boost::condition documentation:
http://boost.org/doc/html/condition.html
#4 on "condition waiting" is wrong; they left out the boost::xtime
parameter.
Thanks,
Adam
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