On 13/03/2018, Sage Weil wrote: > I think one wrinkle is that we have lots of lines like > > assert(lock.is_locked_by_me()); > > sprinkled about, usually at the top of internal _foo() methods. I > don't think there is a std::mutex equivalent (that operates on the > mutex itself and not a std::unique_lock). > > I'm not sure if it's worth trying to keep something like this around > for the debug_mutex... I think we'd need to create some sort of > macro like ASSERT_MUTEX_LOCKED(lock) that compiles away to nothing > in the std::mutex case? If you /reallyreallyreally/ want something like this, then the way I would want to do it is pass in a reference (possibly const) to a unique_lock: And have a macro like: #define ASSERT_MUTEX_HELD(ul, m) \ ceph_assert(ul.mutex() == m && ul.owns_lock()) This way we can have our assertions whether we have the Magic Debug Mutex or not. Alternatively we could make our own templatized Fancy Schmancy version of lock guard templatized on the mutex of the class and just have functions that require a reference to it be passed in in the type signature. This saves us from runtime checks, at least. -- Senior Software Engineer Red Hat Storage, Ann Arbor, MI, US IRC: Aemerson@OFTC, Actinic@Freenode 0x80F7544B90EDBFB9 E707 86BA 0C1B 62CC 152C 7C12 80F7 544B 90ED BFB9 -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html