]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
common: use std::mutex and friends if NDEBUG
authorKefu Chai <kchai@redhat.com>
Wed, 15 Aug 2018 11:02:23 +0000 (19:02 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 16 Aug 2018 09:33:48 +0000 (17:33 +0800)
commit362e3dbaa4da521a8d3c6ffc977c81a9d0219e5a
tree334afb4d3de264afd885d821e79f73e9e4253d13
parent8bf5d0975efc0a96c18c904424c49adb80bf73b4
common: use std::mutex and friends if NDEBUG

revise LockCond and its friends to satisfy the concepts of their
counterparts in C++ standard library, so they can used as drop-in
replacements of them.

and use std::mutex, std::condition_variables, std::shared_mutex
if NDEBUG is defined for better performance.

the reason i specialize LockMutex<LockPolicy::MUTEX> to offer the
alias of std::mutex instead inheriting from it as SharedMutex,
is that, std::condition_variable::wait() requires
`std::unique_lock<std::mutex>&`, not
`std::unique_lock<subclass_of_mutex>&` as its parameter.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/lock_cond.h
src/common/lock_mutex.h
src/common/lock_shared_mutex.h [new file with mode: 0644]
src/common/shared_cache.hpp
src/test/common/test_shared_cache.cc