Subj : Re: Lockable objects To : comp.programming.threads From : Giancarlo Niccolai Date : Sat May 21 2005 03:12 pm Uenal Mutlu wrote: > > void f() > { // requires that object must be locked before calling this func > assert(!m.IsLocked()); > //... > } > So you are serious. Ok. However, got a better one: void f() { lock( &x ); // it's locked here. unlock( &x ); } IsLocked() suggests that you may call a function with or without a mutex locked. A well designed application NEVER calls a function while holding a mutex, unless very very special cases. In a few words, you should NOT call any function between a lock() and an unlock(). That because mutexes protect data, and function calls are not data to protect. If you need to, then you must use a condition wait; they are meant to wait for something to relevant to happen, i.e. for the data you want to use to be ready. You are confusing too much the two things, I am afraid. Oh, but there aren't condition waits in Windows... sorry... However, someone created them for you. Giancarlo. .