Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2004-07-07 13:57:03


On Jul 7, 2004, at 1:45 PM, Peter Dimov wrote:

> My proposal (I'm not sure whether I should be credited for it; Howard
> posted
> locks that had these properties and I merely commented) can be made to
> break
> such code at compile time, simply by removing the nested
> TryMutex::scoped_try_lock typedef (as there is no longer a need for it,
> because ::scoped_lock is a TryLock or TimedLock, as appropriate).

Interesting... I hadn't thought about doing that. But I think I see
where you're headed. A lock is just a lock, those parts of it you
need, you instantiate and use. Those parts you don't, you ignore and
they don't hurt anything (unless you try to explicitly instantiate your
lock). If you try to use something the templated mutex doesn't
support, you get a compile time error. Giving that some more
thought...

My intention with the read/write lock stuff was simply that these guys
needed to at least support try locks. That is needed so that you can
do assign-like locking between two objects:

{
lock_both<write_lock, read_lock> l(a.mut(), b.mut());
a = b;
}

Without try locks, lock_both can't be made to work without risking
deadlock.

-Howard


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk