aboutsummaryrefslogtreecommitdiff
path: root/contrib/libc++/include/shared_mutex
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libc++/include/shared_mutex')
-rw-r--r--contrib/libc++/include/shared_mutex50
1 files changed, 28 insertions, 22 deletions
diff --git a/contrib/libc++/include/shared_mutex b/contrib/libc++/include/shared_mutex
index 5b1f53aafe81..9b7f0bf77354 100644
--- a/contrib/libc++/include/shared_mutex
+++ b/contrib/libc++/include/shared_mutex
@@ -19,14 +19,14 @@
namespace std
{
-class shared_mutex
+class shared_timed_mutex
{
public:
- shared_mutex();
- ~shared_mutex();
+ shared_timed_mutex();
+ ~shared_timed_mutex();
- shared_mutex(const shared_mutex&) = delete;
- shared_mutex& operator=(const shared_mutex&) = delete;
+ shared_timed_mutex(const shared_timed_mutex&) = delete;
+ shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
// Exclusive ownership
void lock(); // blocking
@@ -112,9 +112,13 @@ template <class Mutex>
#pragma GCC system_header
#endif
+#ifdef _LIBCPP_HAS_NO_THREADS
+#error <shared_mutex> is not supported on this single threaded system
+#else // !_LIBCPP_HAS_NO_THREADS
+
_LIBCPP_BEGIN_NAMESPACE_STD
-class _LIBCPP_TYPE_VIS shared_mutex
+class _LIBCPP_TYPE_VIS shared_timed_mutex
{
mutex __mut_;
condition_variable __gate1_;
@@ -124,11 +128,11 @@ class _LIBCPP_TYPE_VIS shared_mutex
static const unsigned __write_entered_ = 1U << (sizeof(unsigned)*__CHAR_BIT__ - 1);
static const unsigned __n_readers_ = ~__write_entered_;
public:
- shared_mutex();
- _LIBCPP_INLINE_VISIBILITY ~shared_mutex() = default;
+ shared_timed_mutex();
+ _LIBCPP_INLINE_VISIBILITY ~shared_timed_mutex() = default;
- shared_mutex(const shared_mutex&) = delete;
- shared_mutex& operator=(const shared_mutex&) = delete;
+ shared_timed_mutex(const shared_timed_mutex&) = delete;
+ shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
// Exclusive ownership
void lock();
@@ -163,7 +167,7 @@ public:
template <class _Clock, class _Duration>
bool
-shared_mutex::try_lock_until(
+shared_timed_mutex::try_lock_until(
const chrono::time_point<_Clock, _Duration>& __abs_time)
{
unique_lock<mutex> __lk(__mut_);
@@ -198,7 +202,7 @@ shared_mutex::try_lock_until(
template <class _Clock, class _Duration>
bool
-shared_mutex::try_lock_shared_until(
+shared_timed_mutex::try_lock_shared_until(
const chrono::time_point<_Clock, _Duration>& __abs_time)
{
unique_lock<mutex> __lk(__mut_);
@@ -232,7 +236,7 @@ private:
public:
_LIBCPP_INLINE_VISIBILITY
- shared_lock() noexcept
+ shared_lock() _NOEXCEPT
: __m_(nullptr),
__owns_(false)
{}
@@ -244,7 +248,7 @@ public:
{__m_->lock_shared();}
_LIBCPP_INLINE_VISIBILITY
- shared_lock(mutex_type& __m, defer_lock_t) noexcept
+ shared_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
: __m_(&__m),
__owns_(false)
{}
@@ -288,7 +292,7 @@ public:
shared_lock& operator=(shared_lock const&) = delete;
_LIBCPP_INLINE_VISIBILITY
- shared_lock(shared_lock&& __u) noexcept
+ shared_lock(shared_lock&& __u) _NOEXCEPT
: __m_(__u.__m_),
__owns_(__u.__owns_)
{
@@ -297,7 +301,7 @@ public:
}
_LIBCPP_INLINE_VISIBILITY
- shared_lock& operator=(shared_lock&& __u) noexcept
+ shared_lock& operator=(shared_lock&& __u) _NOEXCEPT
{
if (__owns_)
__m_->unlock_shared();
@@ -320,14 +324,14 @@ public:
// Setters
_LIBCPP_INLINE_VISIBILITY
- void swap(shared_lock& __u) noexcept
+ void swap(shared_lock& __u) _NOEXCEPT
{
_VSTD::swap(__m_, __u.__m_);
_VSTD::swap(__owns_, __u.__owns_);
}
_LIBCPP_INLINE_VISIBILITY
- mutex_type* release() noexcept
+ mutex_type* release() _NOEXCEPT
{
mutex_type* __m = __m_;
__m_ = nullptr;
@@ -337,13 +341,13 @@ public:
// Getters
_LIBCPP_INLINE_VISIBILITY
- bool owns_lock() const noexcept {return __owns_;}
+ bool owns_lock() const _NOEXCEPT {return __owns_;}
_LIBCPP_INLINE_VISIBILITY
- explicit operator bool () const noexcept {return __owns_;}
+ explicit operator bool () const _NOEXCEPT {return __owns_;}
_LIBCPP_INLINE_VISIBILITY
- mutex_type* mutex() const noexcept {return __m_;}
+ mutex_type* mutex() const _NOEXCEPT {return __m_;}
};
template <class _Mutex>
@@ -409,11 +413,13 @@ shared_lock<_Mutex>::unlock()
template <class _Mutex>
inline _LIBCPP_INLINE_VISIBILITY
void
-swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) noexcept
+swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) _NOEXCEPT
{__x.swap(__y);}
_LIBCPP_END_NAMESPACE_STD
+#endif // !_LIBCPP_HAS_NO_THREADS
+
#endif // _LIBCPP_STD_VER > 11
#endif // _LIBCPP_SHARED_MUTEX