Inquiry functions for lock classes - possible?



in the recent days i was struggling with a debugging problem related to thread synchronization and the following idea came to my mind: wouldn’t it be very helpful, if the lock classes such as CriticalSection would provide some inquiry functions, where one could check whether or not the mutex is currently locked by this (currently running) or another thread. so you could write something like:

[code]void MyClass::myFunction()

jassert( myLock.isLockedByThisThread() );
// you should aquire the lock before calling that function

jassert( !myLock.isLockedByAnotherThread() );
// blah blah

jassert( !myLock.isLockedByThread(someThread) );
// blub blub

looking at the pthreads doc, there seems to be nothing that supports this - is it technically possible at all? or is there possibly a fundamental flaw in this idea?

@jules: don’t see this as an immediate feature request, more as an idea / food for thought