Boost logo

Boost :

From: William Kempf (sirwillard_at_[hidden])
Date: 2000-09-15 08:36:41

--- In boost_at_[hidden], Branko Èibej <branko.cibej_at_h...> wrote:
> I think this is a real problem, but you don't need to expose
> lock() and unlock() to solve it. Instead you have a lock-inverter
> class (which must be a friend of lock, yes, but I think that's
> justified in this case):

> Your example becomes:
> {
> boost::lock lock(m);
> for (int i = a.get(); i < 10;
> {
> <some code>
> {
> boost::invert_lock unlock(lock);
> f();
> }
> <some code>
> }
> }

This just compounds the problem. The inverter now locks you into the
same scope requirements as the original lock, which will be just as
big of a problem (very small, IMHO, but I think everyone's admitted
that it can occur). Further, this inverter is worse than the
unsafe_lock<> approach because it can "invalidate" *ANY* lock
removing *ALL* runtime checking in condition::wait().

Bill Kempf

Boost list run by bdawes at, gregod at, cpdaniel at, john at