aboutsummaryrefslogtreecommitdiffstats
path: root/src/mutex.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mutex.cpp')
-rw-r--r--src/mutex.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/mutex.cpp b/src/mutex.cpp
index 0d69d7cacfa1..7e979cd89041 100644
--- a/src/mutex.cpp
+++ b/src/mutex.cpp
@@ -13,7 +13,7 @@
#include "__undef_macros"
#ifndef _LIBCPP_HAS_NO_THREADS
-#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
+#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
#pragma comment(lib, "pthread")
#endif
#endif
@@ -21,9 +21,9 @@
_LIBCPP_BEGIN_NAMESPACE_STD
#ifndef _LIBCPP_HAS_NO_THREADS
-const defer_lock_t defer_lock = {};
-const try_to_lock_t try_to_lock = {};
-const adopt_lock_t adopt_lock = {};
+const defer_lock_t defer_lock{};
+const try_to_lock_t try_to_lock{};
+const adopt_lock_t adopt_lock{};
// ~mutex is defined elsewhere
@@ -132,7 +132,7 @@ timed_mutex::unlock() _NOEXCEPT
recursive_timed_mutex::recursive_timed_mutex()
: __count_(0),
- __id_(0)
+ __id_{}
{
}
@@ -144,9 +144,9 @@ recursive_timed_mutex::~recursive_timed_mutex()
void
recursive_timed_mutex::lock()
{
- __libcpp_thread_id id = __libcpp_thread_get_current_id();
+ __thread_id id = this_thread::get_id();
unique_lock<mutex> lk(__m_);
- if (__libcpp_thread_id_equal(id, __id_))
+ if (id ==__id_)
{
if (__count_ == numeric_limits<size_t>::max())
__throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
@@ -162,9 +162,9 @@ recursive_timed_mutex::lock()
bool
recursive_timed_mutex::try_lock() _NOEXCEPT
{
- __libcpp_thread_id id = __libcpp_thread_get_current_id();
+ __thread_id id = this_thread::get_id();
unique_lock<mutex> lk(__m_, try_to_lock);
- if (lk.owns_lock() && (__count_ == 0 || __libcpp_thread_id_equal(id, __id_)))
+ if (lk.owns_lock() && (__count_ == 0 || id == __id_))
{
if (__count_ == numeric_limits<size_t>::max())
return false;
@@ -181,7 +181,7 @@ recursive_timed_mutex::unlock() _NOEXCEPT
unique_lock<mutex> lk(__m_);
if (--__count_ == 0)
{
- __id_ = 0;
+ __id_.__reset();
lk.unlock();
__cv_.notify_one();
}