summaryrefslogtreecommitdiffstats
path: root/libcxx/src/mutex.cpp
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2019-08-14 16:21:27 +0000
committerMarshall Clow <mclow.lists@gmail.com>2019-08-14 16:21:27 +0000
commit2b1d42541f20ce919c7841328934f64366e39d7c (patch)
tree34344f7fe94faf4de6f5cb6574be9328b5ee3a65 /libcxx/src/mutex.cpp
parent2be59170d433be05204992838a1aadbc79d5e0d1 (diff)
downloadbcm5719-llvm-2b1d42541f20ce919c7841328934f64366e39d7c.tar.gz
bcm5719-llvm-2b1d42541f20ce919c7841328934f64366e39d7c.zip
Rework recursive_timed_mutex so that it uses __thread_id instead of using the lower-level __libcpp_thread_id. This is prep for fixing PR42918. Reviewed as https://reviews.llvm.org/D65895
llvm-svn: 368867
Diffstat (limited to 'libcxx/src/mutex.cpp')
-rw-r--r--libcxx/src/mutex.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/libcxx/src/mutex.cpp b/libcxx/src/mutex.cpp
index e741432db19..ddd36b4977e 100644
--- a/libcxx/src/mutex.cpp
+++ b/libcxx/src/mutex.cpp
@@ -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();
}
OpenPOWER on IntegriCloud