Boost logo

Boost :

From: Glen Knowles (gknowles_at_[hidden])
Date: 2004-07-09 18:10:23

> From: Howard Hinnant [mailto:hinnant_at_[hidden]]
> 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.

Lock_both can be made to work with try locks? Either you have a way to
deterministicly set the order you lock the mutexes or you have problems. You
can avoid deadlocking with try lock, but you will fail to get the pair of
locks in cases were you would have gotten it by waiting. I suppose you could
just keep try-locking both ways until you get it, but that's not good for
performance. :)

One solution to this problem would be mutex::operator<


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