
boost is back up, yea! :-) On Jul 5, 2004, at 4:33 PM, Peter Dimov wrote:
Howard Hinnant wrote:
On Jun 29, 2004, at 12:30 PM, Michael Glassford wrote:
Also, you could end up with some interesting situations like this:
[...]
Let's assume that the guarded entity is
int x;
void f(read_write_mutex m) { read_write_mutex::read_lock r(m);
int y = x;
if (...) { read_write_mutex::write_lock w(r); //lock promotion
assert( x == y); // always holds, we had a read+ lock all the time
I'm not following that x==y always holds. If two threads concurrently hold a read lock, and concurrently try to obtain a write lock, only one thread will get the write lock, the other will block. Assuming the one thread that got the write lock changes x, then the thread that blocked will fire its assert when it finally unblocks and gets the write lock. What am I missing? -Howard