
"Peter Dimov" <pdimov@mmltd.net> writes:
David Abrahams wrote:
Matt Hurd <matt.hurd@gmail.com> writes:
On Wed, 14 Jul 2004 15:27:08 -0400, David Abrahams <dave@boost-consulting.com> wrote:
"Peter Dimov" <pdimov@mmltd.net> writes:
Can't you just check the hashes and only lock once in that case?
AFAICT, you'd have to record the objects to which the specific thread had the lock otherwise you can't discriminate on who owns the lock.
That's only true if a given thread can lock more than two objects at the same time. Isn't that likely to lead to deadlock, regardless?
Yep, have you read the last sentence in the block you quoted?
Yes, but I don't see how it's relevant.
Anyway: consider this (oversimplified) situation:
// f.cpp
static object o;
void f() { lock( &o ); // do things unlock( &o ); }
// g.cpp
void f();
static object o2;
void g() { lock( &o2 ); f(); unlock( &o2 ); }
Since the f() lock is always nested within the g() lock, there can be no deadlock.
Sorry, I don't see more than two objects locked at the same time here. No big deal, I'm probably off base here so will relurk. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com