From ac417faebc02fe301cb2764ff2bdabf9cccfeaa6 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Sun, 28 Nov 2010 19:41:07 +0000 Subject: [PATCH] Minor fixup in and add optional support for shared_mutex and upgrade_mutex which must be opted into with #define _LIBCPP_SHARED_LOCK git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@120258 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/__mutex_base | 32 ++++++++++++++++++++++++++++++++ include/ratio | 20 ++++---------------- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/include/__mutex_base b/include/__mutex_base index d3b2a1be6..3bc0b5baf 100644 --- a/include/__mutex_base +++ b/include/__mutex_base @@ -18,6 +18,16 @@ #pragma GCC system_header +#ifdef _LIBCPP_SHARED_LOCK + +namespace ting { +template class shared_lock; +template class upgrade_lock; +} + +#endif // _LIBCPP_SHARED_LOCK + + _LIBCPP_BEGIN_NAMESPACE_STD class _LIBCPP_VISIBLE mutex @@ -143,6 +153,28 @@ public: __u.__owns_ = false; return *this; } + +#ifdef _LIBCPP_SHARED_LOCK + + unique_lock(ting::shared_lock&&, try_to_lock_t); + template + unique_lock(ting::shared_lock&&, + const chrono::time_point<_Clock, _Duration>&); + template + unique_lock(ting::shared_lock&&, + const chrono::duration<_Rep, _Period>&); + + explicit unique_lock(ting::upgrade_lock&&); + unique_lock(ting::upgrade_lock&&, try_to_lock_t); + template + unique_lock(ting::upgrade_lock&&, + const chrono::time_point<_Clock, _Duration>&); + template + unique_lock(ting::upgrade_lock&&, + const chrono::duration<_Rep, _Period>&); + +#endif // _LIBCPP_SHARED_LOCK + #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES void lock(); diff --git a/include/ratio b/include/ratio index b9b43d838..7369ccf5d 100644 --- a/include/ratio +++ b/include/ratio @@ -276,10 +276,7 @@ public: template struct _LIBCPP_VISIBLE ratio_multiply - : public __ratio_multiply<_R1, _R2>::type -{ - typedef typename __ratio_multiply<_R1, _R2>::type type; -}; + : public __ratio_multiply<_R1, _R2>::type {}; template struct __ratio_divide @@ -297,10 +294,7 @@ public: template struct _LIBCPP_VISIBLE ratio_divide - : public __ratio_divide<_R1, _R2>::type -{ - typedef typename __ratio_divide<_R1, _R2>::type type; -}; + : public __ratio_divide<_R1, _R2>::type {}; template struct __ratio_add @@ -326,10 +320,7 @@ public: template struct _LIBCPP_VISIBLE ratio_add - : public __ratio_add<_R1, _R2>::type -{ - typedef typename __ratio_add<_R1, _R2>::type type; -}; + : public __ratio_add<_R1, _R2>::type {}; template struct __ratio_subtract @@ -355,10 +346,7 @@ public: template struct _LIBCPP_VISIBLE ratio_subtract - : public __ratio_subtract<_R1, _R2>::type -{ - typedef typename __ratio_subtract<_R1, _R2>::type type; -}; + : public __ratio_subtract<_R1, _R2>::type {}; // ratio_equal