Implement N3891: A proposal to rename shared_mutex to shared_timed_mutex

This is as straightforward as it sounds, a renamed from shared_mutex to
shared_timed_mutex.

Note that libcxx .dylib and .so files built with c++14 support need to
be rebuilt.

llvm-svn: 204078
This commit is contained in:
David Majnemer 2014-03-17 20:19:44 +00:00
parent 2fd6f512e5
commit 7ec93f9b1c
30 changed files with 92 additions and 92 deletions

View File

@ -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
@ -114,7 +114,7 @@ template <class Mutex>
_LIBCPP_BEGIN_NAMESPACE_STD
class _LIBCPP_TYPE_VIS shared_mutex
class _LIBCPP_TYPE_VIS shared_timed_mutex
{
mutex __mut_;
condition_variable __gate1_;
@ -124,11 +124,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 +163,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 +198,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_);

View File

@ -12,7 +12,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
shared_mutex::shared_mutex()
shared_timed_mutex::shared_timed_mutex()
: __state_(0)
{
}
@ -20,7 +20,7 @@ shared_mutex::shared_mutex()
// Exclusive ownership
void
shared_mutex::lock()
shared_timed_mutex::lock()
{
unique_lock<mutex> lk(__mut_);
while (__state_ & __write_entered_)
@ -31,7 +31,7 @@ shared_mutex::lock()
}
bool
shared_mutex::try_lock()
shared_timed_mutex::try_lock()
{
unique_lock<mutex> lk(__mut_);
if (__state_ == 0)
@ -43,7 +43,7 @@ shared_mutex::try_lock()
}
void
shared_mutex::unlock()
shared_timed_mutex::unlock()
{
lock_guard<mutex> _(__mut_);
__state_ = 0;
@ -53,7 +53,7 @@ shared_mutex::unlock()
// Shared ownership
void
shared_mutex::lock_shared()
shared_timed_mutex::lock_shared()
{
unique_lock<mutex> lk(__mut_);
while ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_)
@ -64,7 +64,7 @@ shared_mutex::lock_shared()
}
bool
shared_mutex::try_lock_shared()
shared_timed_mutex::try_lock_shared()
{
unique_lock<mutex> lk(__mut_);
unsigned num_readers = __state_ & __n_readers_;
@ -79,7 +79,7 @@ shared_mutex::try_lock_shared()
}
void
shared_mutex::unlock_shared()
shared_timed_mutex::unlock_shared()
{
lock_guard<mutex> _(__mut_);
unsigned num_readers = (__state_ & __n_readers_) - 1;

View File

@ -17,16 +17,16 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m0;
std::shared_mutex m1;
std::shared_timed_mutex m0;
std::shared_timed_mutex m1;
#endif // _LIBCPP_STD_VER > 11
int main()
{
#if _LIBCPP_STD_VER > 11
std::shared_lock<std::shared_mutex> lk0(m0);
std::shared_lock<std::shared_mutex> lk1(m1);
std::shared_lock<std::shared_timed_mutex> lk0(m0);
std::shared_lock<std::shared_timed_mutex> lk1(m1);
lk1 = lk0;
#else
# error

View File

@ -16,14 +16,14 @@
#include <shared_mutex>
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
#endif // _LIBCPP_STD_VER > 11
int main()
{
#if _LIBCPP_STD_VER > 11
std::shared_lock<std::shared_mutex> lk0(m);
std::shared_lock<std::shared_mutex> lk = lk0;
std::shared_lock<std::shared_timed_mutex> lk0(m);
std::shared_lock<std::shared_timed_mutex> lk = lk0;
#else
# error
#endif // _LIBCPP_STD_VER > 11

View File

@ -19,7 +19,7 @@
int main()
{
#if _LIBCPP_STD_VER > 11
std::shared_lock<std::shared_mutex> ul;
std::shared_lock<std::shared_timed_mutex> ul;
assert(!ul.owns_lock());
assert(ul.mutex() == nullptr);
#endif // _LIBCPP_STD_VER > 11

View File

@ -18,16 +18,16 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m0;
std::shared_mutex m1;
std::shared_timed_mutex m0;
std::shared_timed_mutex m1;
#endif // _LIBCPP_STD_VER > 11
int main()
{
#if _LIBCPP_STD_VER > 11
std::shared_lock<std::shared_mutex> lk0(m0);
std::shared_lock<std::shared_mutex> lk1(m1);
std::shared_lock<std::shared_timed_mutex> lk0(m0);
std::shared_lock<std::shared_timed_mutex> lk1(m1);
lk1 = std::move(lk0);
assert(lk1.mutex() == &m0);
assert(lk1.owns_lock() == true);

View File

@ -17,14 +17,14 @@
#include <cassert>
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
#endif // _LIBCPP_STD_VER > 11
int main()
{
#if _LIBCPP_STD_VER > 11
std::shared_lock<std::shared_mutex> lk0(m);
std::shared_lock<std::shared_mutex> lk = std::move(lk0);
std::shared_lock<std::shared_timed_mutex> lk0(m);
std::shared_lock<std::shared_timed_mutex> lk = std::move(lk0);
assert(lk.mutex() == &m);
assert(lk.owns_lock() == true);
assert(lk0.mutex() == nullptr);

View File

@ -21,7 +21,7 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
typedef std::chrono::system_clock Clock;
typedef Clock::time_point time_point;
@ -34,7 +34,7 @@ void f()
time_point t0 = Clock::now();
time_point t1;
{
std::shared_lock<std::shared_mutex> ul(m);
std::shared_lock<std::shared_timed_mutex> ul(m);
t1 = Clock::now();
}
ns d = t1 - t0 - ms(250);
@ -46,7 +46,7 @@ void g()
time_point t0 = Clock::now();
time_point t1;
{
std::shared_lock<std::shared_mutex> ul(m);
std::shared_lock<std::shared_timed_mutex> ul(m);
t1 = Clock::now();
}
ns d = t1 - t0;

View File

@ -19,9 +19,9 @@
int main()
{
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
m.lock();
std::shared_lock<std::shared_mutex> lk(m, std::adopt_lock);
std::shared_lock<std::shared_timed_mutex> lk(m, std::adopt_lock);
assert(lk.mutex() == &m);
assert(lk.owns_lock() == true);
#endif // _LIBCPP_STD_VER > 11

View File

@ -19,8 +19,8 @@
int main()
{
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_lock<std::shared_mutex> lk(m, std::defer_lock);
std::shared_timed_mutex m;
std::shared_lock<std::shared_timed_mutex> lk(m, std::defer_lock);
assert(lk.mutex() == &m);
assert(lk.owns_lock() == false);
#endif // _LIBCPP_STD_VER > 11

View File

@ -22,7 +22,7 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
typedef std::chrono::steady_clock Clock;
typedef Clock::time_point time_point;
@ -33,7 +33,7 @@ typedef std::chrono::nanoseconds ns;
void f1()
{
time_point t0 = Clock::now();
std::shared_lock<std::shared_mutex> lk(m, ms(300));
std::shared_lock<std::shared_timed_mutex> lk(m, ms(300));
assert(lk.owns_lock() == true);
time_point t1 = Clock::now();
ns d = t1 - t0 - ms(250);
@ -43,7 +43,7 @@ void f1()
void f2()
{
time_point t0 = Clock::now();
std::shared_lock<std::shared_mutex> lk(m, ms(250));
std::shared_lock<std::shared_timed_mutex> lk(m, ms(250));
assert(lk.owns_lock() == false);
time_point t1 = Clock::now();
ns d = t1 - t0 - ms(250);

View File

@ -9,7 +9,7 @@
// <shared_mutex>
// class shared_mutex;
// class shared_timed_mutex;
// template <class Clock, class Duration>
// shared_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
@ -22,7 +22,7 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
typedef std::chrono::steady_clock Clock;
typedef Clock::time_point time_point;
@ -33,7 +33,7 @@ typedef std::chrono::nanoseconds ns;
void f1()
{
time_point t0 = Clock::now();
std::shared_lock<std::shared_mutex> lk(m, Clock::now() + ms(300));
std::shared_lock<std::shared_timed_mutex> lk(m, Clock::now() + ms(300));
assert(lk.owns_lock() == true);
time_point t1 = Clock::now();
ns d = t1 - t0 - ms(250);
@ -43,7 +43,7 @@ void f1()
void f2()
{
time_point t0 = Clock::now();
std::shared_lock<std::shared_mutex> lk(m, Clock::now() + ms(250));
std::shared_lock<std::shared_timed_mutex> lk(m, Clock::now() + ms(250));
assert(lk.owns_lock() == false);
time_point t1 = Clock::now();
ns d = t1 - t0 - ms(250);

View File

@ -21,7 +21,7 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
typedef std::chrono::system_clock Clock;
typedef Clock::time_point time_point;
@ -33,20 +33,20 @@ void f()
{
time_point t0 = Clock::now();
{
std::shared_lock<std::shared_mutex> lk(m, std::try_to_lock);
std::shared_lock<std::shared_timed_mutex> lk(m, std::try_to_lock);
assert(lk.owns_lock() == false);
}
{
std::shared_lock<std::shared_mutex> lk(m, std::try_to_lock);
std::shared_lock<std::shared_timed_mutex> lk(m, std::try_to_lock);
assert(lk.owns_lock() == false);
}
{
std::shared_lock<std::shared_mutex> lk(m, std::try_to_lock);
std::shared_lock<std::shared_timed_mutex> lk(m, std::try_to_lock);
assert(lk.owns_lock() == false);
}
while (true)
{
std::shared_lock<std::shared_mutex> lk(m, std::try_to_lock);
std::shared_lock<std::shared_timed_mutex> lk(m, std::try_to_lock);
if (lk.owns_lock())
break;
}

View File

@ -21,7 +21,7 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
typedef std::chrono::system_clock Clock;
typedef Clock::time_point time_point;
@ -31,7 +31,7 @@ typedef std::chrono::nanoseconds ns;
void f()
{
std::shared_lock<std::shared_mutex> lk(m, std::defer_lock);
std::shared_lock<std::shared_timed_mutex> lk(m, std::defer_lock);
time_point t0 = Clock::now();
lk.lock();
time_point t1 = Clock::now();

View File

@ -18,16 +18,16 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
#endif // _LIBCPP_STD_VER > 11
int main()
{
#if _LIBCPP_STD_VER > 11
std::shared_lock<std::shared_mutex> lk0;
std::shared_lock<std::shared_timed_mutex> lk0;
assert(lk0.mutex() == nullptr);
std::shared_lock<std::shared_mutex> lk1(m);
std::shared_lock<std::shared_timed_mutex> lk1(m);
assert(lk1.mutex() == &m);
lk1.unlock();
assert(lk1.mutex() == &m);

View File

@ -18,16 +18,16 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
#endif // _LIBCPP_STD_VER > 11
int main()
{
#if _LIBCPP_STD_VER > 11
std::shared_lock<std::shared_mutex> lk0;
std::shared_lock<std::shared_timed_mutex> lk0;
assert(static_cast<bool>(lk0) == false);
std::shared_lock<std::shared_mutex> lk1(m);
std::shared_lock<std::shared_timed_mutex> lk1(m);
assert(static_cast<bool>(lk1) == true);
lk1.unlock();
assert(static_cast<bool>(lk1) == false);

View File

@ -18,16 +18,16 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
#endif // _LIBCPP_STD_VER > 11
int main()
{
#if _LIBCPP_STD_VER > 11
std::shared_lock<std::shared_mutex> lk0;
std::shared_lock<std::shared_timed_mutex> lk0;
assert(lk0.owns_lock() == false);
std::shared_lock<std::shared_mutex> lk1(m);
std::shared_lock<std::shared_timed_mutex> lk1(m);
assert(lk1.owns_lock() == true);
lk1.unlock();
assert(lk1.owns_lock() == false);

View File

@ -9,17 +9,17 @@
// <shared_mutex>
// class shared_mutex;
// class shared_timed_mutex;
// shared_mutex& operator=(const shared_mutex&) = delete;
// shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
#include <shared_mutex>
int main()
{
#if _LIBCPP_STD_VER > 11
std::shared_mutex m0;
std::shared_mutex m1;
std::shared_timed_mutex m0;
std::shared_timed_mutex m1;
m1 = m0;
#else
# error

View File

@ -9,17 +9,17 @@
// <shared_mutex>
// class shared_mutex;
// class shared_timed_mutex;
// shared_mutex(const shared_mutex&) = delete;
// shared_timed_mutex(const shared_timed_mutex&) = delete;
#include <shared_mutex>
int main()
{
#if _LIBCPP_STD_VER > 11
std::shared_mutex m0;
std::shared_mutex m1(m0);
std::shared_timed_mutex m0;
std::shared_timed_mutex m1(m0);
#else
# error
#endif

View File

@ -9,15 +9,15 @@
// <shared_mutex>
// class shared_mutex;
// class shared_timed_mutex;
// shared_mutex();
// shared_timed_mutex();
#include <shared_mutex>
int main()
{
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
#endif
}

View File

@ -9,7 +9,7 @@
// <shared_mutex>
// class shared_mutex;
// class shared_timed_mutex;
// void lock();
@ -20,7 +20,7 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
typedef std::chrono::system_clock Clock;
typedef Clock::time_point time_point;

View File

@ -9,7 +9,7 @@
// <shared_mutex>
// class shared_mutex;
// class shared_timed_mutex;
// void lock_shared();
@ -21,7 +21,7 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
typedef std::chrono::system_clock Clock;
typedef Clock::time_point time_point;

View File

@ -9,7 +9,7 @@
// <shared_mutex>
// class shared_mutex;
// class shared_timed_mutex;
// bool try_lock();
@ -20,7 +20,7 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
typedef std::chrono::system_clock Clock;
typedef Clock::time_point time_point;

View File

@ -9,7 +9,7 @@
// <shared_mutex>
// class shared_mutex;
// class shared_timed_mutex;
// template <class Rep, class Period>
// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
@ -21,7 +21,7 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
typedef std::chrono::steady_clock Clock;
typedef Clock::time_point time_point;

View File

@ -9,7 +9,7 @@
// <shared_mutex>
// class shared_mutex;
// class shared_timed_mutex;
// bool try_lock_shared();
@ -21,7 +21,7 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
typedef std::chrono::system_clock Clock;
typedef Clock::time_point time_point;

View File

@ -9,7 +9,7 @@
// <shared_mutex>
// class shared_mutex;
// class shared_timed_mutex;
// template <class Rep, class Period>
// bool try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time);
@ -22,7 +22,7 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
typedef std::chrono::steady_clock Clock;
typedef Clock::time_point time_point;

View File

@ -9,7 +9,7 @@
// <shared_mutex>
// class shared_mutex;
// class shared_timed_mutex;
// template <class Clock, class Duration>
// bool try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time);
@ -22,7 +22,7 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
typedef std::chrono::steady_clock Clock;
typedef Clock::time_point time_point;

View File

@ -9,7 +9,7 @@
// <shared_mutex>
// class shared_mutex;
// class shared_timed_mutex;
// template <class Clock, class Duration>
// bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
@ -21,7 +21,7 @@
#if _LIBCPP_STD_VER > 11
std::shared_mutex m;
std::shared_timed_mutex m;
typedef std::chrono::steady_clock Clock;
typedef Clock::time_point time_point;

View File

@ -101,7 +101,7 @@
<tr><td><a href="http://isocpp.org/files/papers/N3924.pdf">3924</a></td><td>LWG</td><td>Discouraging rand() in C++14</td><td>Issaquah</td><td>Complete</td><td>3.5</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3887">3887</a></td><td>LWG</td><td>Consistent Metafunction Aliases</td><td>Issaquah</td><td>Complete</td><td>3.5</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3891">3891</a></td><td>SG1</td><td>A proposal to rename shared_mutex to shared_timed_mutex</td><td>Issaquah</td><td></td><td></td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3891">3891</a></td><td>SG1</td><td>A proposal to rename shared_mutex to shared_timed_mutex</td><td>Issaquah</td><td>Complete</td><td>3.5</td></tr>
<!-- <tr><td></td><td></td><td></td><td></td><td></td><td></td></tr> -->
</table>