289 | @@ -289,6 +290,13 @@ class CMutexLock
290 | #define WAITABLE_CRITICAL_BLOCK(cs) \
291 | for (bool fcriticalblockonce=true; fcriticalblockonce; assert(("break caught by WAITABLE_CRITICAL_BLOCK!" && !fcriticalblockonce)), fcriticalblockonce=false) \
292 | for (CWaitableCriticalBlock waitablecriticalblock(cs, #cs, __FILE__, __LINE__); fcriticalblockonce; fcriticalblockonce=false)
293 | +*/
294 | +
295 | +#define LOCK(cs) CCriticalBlock criticalblock(cs, #cs, __FILE__, __LINE__)
Hm I'd prefer passing the name of the lock ("criticalblock") as a macro parameter to LOCK, TRY_LOCK and IS_LOCKED. Especially the bare IS_LOCKED (with hardcoded name) look too much like magic to my taste, as there is no visual clue what lock it refers to.
Yes, it's a balance between code size and clean code. Note that the current master already has hardcoded names as well...
Well yes but we're trying to improve. IMO it'd be best to completely get rid of the macros, if possible. But making them less "magical" would already be good.
Maybe add the name argument only for TRY_LOCK? For LOCK and LOCK2 you never need to refer to them anyway.
I considered removing all macros and go to pure boost::interprocess, but there is no way to keep Gavin's fancy deadlock detection then, which needs FILE and LINE to track code locations. I'm fine with just an argument for TRY_LOCK and IS_LOCKED.
You mean boost::thread, please no more boost::interprocess :)
OK, let's do that then.