diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2015-06-30 14:04:14 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2015-06-30 14:04:14 +0000 |
commit | f69ae47128f8ccab863d1344ed5256b55585a053 (patch) | |
tree | d661d562cccd208ba69e6242b51c36d3a1563cac /libcxx/src | |
parent | 0f09313051a40dc388845c84ad88c25dcebb31a1 (diff) | |
download | bcm5719-llvm-f69ae47128f8ccab863d1344ed5256b55585a053.tar.gz bcm5719-llvm-f69ae47128f8ccab863d1344ed5256b55585a053.zip |
Implement N4508: shared_mutex. Reviewed as http://reviews.llvm.org/D10480
llvm-svn: 241067
Diffstat (limited to 'libcxx/src')
-rw-r--r-- | libcxx/src/shared_mutex.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/libcxx/src/shared_mutex.cpp b/libcxx/src/shared_mutex.cpp index 2b78c1feb9f..874aceb1b03 100644 --- a/libcxx/src/shared_mutex.cpp +++ b/libcxx/src/shared_mutex.cpp @@ -15,7 +15,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD -shared_timed_mutex::shared_timed_mutex() +// Shared Mutex Base +__shared_mutex_base::__shared_mutex_base() : __state_(0) { } @@ -23,7 +24,7 @@ shared_timed_mutex::shared_timed_mutex() // Exclusive ownership void -shared_timed_mutex::lock() +__shared_mutex_base::lock() { unique_lock<mutex> lk(__mut_); while (__state_ & __write_entered_) @@ -34,7 +35,7 @@ shared_timed_mutex::lock() } bool -shared_timed_mutex::try_lock() +__shared_mutex_base::try_lock() { unique_lock<mutex> lk(__mut_); if (__state_ == 0) @@ -46,7 +47,7 @@ shared_timed_mutex::try_lock() } void -shared_timed_mutex::unlock() +__shared_mutex_base::unlock() { lock_guard<mutex> _(__mut_); __state_ = 0; @@ -56,7 +57,7 @@ shared_timed_mutex::unlock() // Shared ownership void -shared_timed_mutex::lock_shared() +__shared_mutex_base::lock_shared() { unique_lock<mutex> lk(__mut_); while ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_) @@ -67,7 +68,7 @@ shared_timed_mutex::lock_shared() } bool -shared_timed_mutex::try_lock_shared() +__shared_mutex_base::try_lock_shared() { unique_lock<mutex> lk(__mut_); unsigned num_readers = __state_ & __n_readers_; @@ -82,7 +83,7 @@ shared_timed_mutex::try_lock_shared() } void -shared_timed_mutex::unlock_shared() +__shared_mutex_base::unlock_shared() { lock_guard<mutex> _(__mut_); unsigned num_readers = (__state_ & __n_readers_) - 1; @@ -101,6 +102,16 @@ shared_timed_mutex::unlock_shared() } +// Shared Timed Mutex +// These routines are here for ABI stability +shared_timed_mutex::shared_timed_mutex() : __base() {} +void shared_timed_mutex::lock() { return __base.lock(); } +bool shared_timed_mutex::try_lock() { return __base.try_lock(); } +void shared_timed_mutex::unlock() { return __base.unlock(); } +void shared_timed_mutex::lock_shared() { return __base.lock_shared(); } +bool shared_timed_mutex::try_lock_shared() { return __base.try_lock_shared(); } +void shared_timed_mutex::unlock_shared() { return __base.unlock_shared(); } + _LIBCPP_END_NAMESPACE_STD #endif // !_LIBCPP_HAS_NO_THREADS |