Add unique_lock and lock_guard support for DistributedMutex
Summary: This adds support for the Lockable concept for DistributedMutex through a unique_lock specialization. There is also a corresponding lock_guard specialization. This should cover 95% of usecases very well. The other 5% should probably consider using std::unique_lock, std::lock_guard or folly::Synchronized Note that std::unique_lock and std::lock_guard can be specialized. The standard does not explicitly prevent specializations for these classes as long as the specializations are dependent on user-defined classes. This makes it ok for us to specialize these two interfaces for our folly mutexes. See the quoted paragraph below Section §[namespace.std] > A program may add a template specialization for any standard library > template to namespace std only if the declaration depends on a user-defined > type and the specialization meets the standard library requirements for the > original template and is not explicitly prohibited. The generic lockable wrappers that implement the std::unique_lock and std::lock_guard interfaces are present in folly/synchronization/detail/ProxyLockable.h. The specializations of std::unique_lock and std::lock_guard in namespace std use these implementations. This allows us to stick with a simple specialization for our mutex, which is well-defined per the paragraph above Reviewed By: djwatson Differential Revision: D10377227 fbshipit-source-id: 9f2c50ff5732714c83a79752f58c792e6b2a5e88
Showing
Please register or sign in to comment