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. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@204078 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
cb036e3f2c
commit
f9f95be930
@ -19,14 +19,14 @@
|
|||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
|
|
||||||
class shared_mutex
|
class shared_timed_mutex
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
shared_mutex();
|
shared_timed_mutex();
|
||||||
~shared_mutex();
|
~shared_timed_mutex();
|
||||||
|
|
||||||
shared_mutex(const shared_mutex&) = delete;
|
shared_timed_mutex(const shared_timed_mutex&) = delete;
|
||||||
shared_mutex& operator=(const shared_mutex&) = delete;
|
shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
|
||||||
|
|
||||||
// Exclusive ownership
|
// Exclusive ownership
|
||||||
void lock(); // blocking
|
void lock(); // blocking
|
||||||
@ -114,7 +114,7 @@ template <class Mutex>
|
|||||||
|
|
||||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||||
|
|
||||||
class _LIBCPP_TYPE_VIS shared_mutex
|
class _LIBCPP_TYPE_VIS shared_timed_mutex
|
||||||
{
|
{
|
||||||
mutex __mut_;
|
mutex __mut_;
|
||||||
condition_variable __gate1_;
|
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 __write_entered_ = 1U << (sizeof(unsigned)*__CHAR_BIT__ - 1);
|
||||||
static const unsigned __n_readers_ = ~__write_entered_;
|
static const unsigned __n_readers_ = ~__write_entered_;
|
||||||
public:
|
public:
|
||||||
shared_mutex();
|
shared_timed_mutex();
|
||||||
_LIBCPP_INLINE_VISIBILITY ~shared_mutex() = default;
|
_LIBCPP_INLINE_VISIBILITY ~shared_timed_mutex() = default;
|
||||||
|
|
||||||
shared_mutex(const shared_mutex&) = delete;
|
shared_timed_mutex(const shared_timed_mutex&) = delete;
|
||||||
shared_mutex& operator=(const shared_mutex&) = delete;
|
shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
|
||||||
|
|
||||||
// Exclusive ownership
|
// Exclusive ownership
|
||||||
void lock();
|
void lock();
|
||||||
@ -163,7 +163,7 @@ public:
|
|||||||
|
|
||||||
template <class _Clock, class _Duration>
|
template <class _Clock, class _Duration>
|
||||||
bool
|
bool
|
||||||
shared_mutex::try_lock_until(
|
shared_timed_mutex::try_lock_until(
|
||||||
const chrono::time_point<_Clock, _Duration>& __abs_time)
|
const chrono::time_point<_Clock, _Duration>& __abs_time)
|
||||||
{
|
{
|
||||||
unique_lock<mutex> __lk(__mut_);
|
unique_lock<mutex> __lk(__mut_);
|
||||||
@ -198,7 +198,7 @@ shared_mutex::try_lock_until(
|
|||||||
|
|
||||||
template <class _Clock, class _Duration>
|
template <class _Clock, class _Duration>
|
||||||
bool
|
bool
|
||||||
shared_mutex::try_lock_shared_until(
|
shared_timed_mutex::try_lock_shared_until(
|
||||||
const chrono::time_point<_Clock, _Duration>& __abs_time)
|
const chrono::time_point<_Clock, _Duration>& __abs_time)
|
||||||
{
|
{
|
||||||
unique_lock<mutex> __lk(__mut_);
|
unique_lock<mutex> __lk(__mut_);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||||
|
|
||||||
shared_mutex::shared_mutex()
|
shared_timed_mutex::shared_timed_mutex()
|
||||||
: __state_(0)
|
: __state_(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -20,7 +20,7 @@ shared_mutex::shared_mutex()
|
|||||||
// Exclusive ownership
|
// Exclusive ownership
|
||||||
|
|
||||||
void
|
void
|
||||||
shared_mutex::lock()
|
shared_timed_mutex::lock()
|
||||||
{
|
{
|
||||||
unique_lock<mutex> lk(__mut_);
|
unique_lock<mutex> lk(__mut_);
|
||||||
while (__state_ & __write_entered_)
|
while (__state_ & __write_entered_)
|
||||||
@ -31,7 +31,7 @@ shared_mutex::lock()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
shared_mutex::try_lock()
|
shared_timed_mutex::try_lock()
|
||||||
{
|
{
|
||||||
unique_lock<mutex> lk(__mut_);
|
unique_lock<mutex> lk(__mut_);
|
||||||
if (__state_ == 0)
|
if (__state_ == 0)
|
||||||
@ -43,7 +43,7 @@ shared_mutex::try_lock()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
shared_mutex::unlock()
|
shared_timed_mutex::unlock()
|
||||||
{
|
{
|
||||||
lock_guard<mutex> _(__mut_);
|
lock_guard<mutex> _(__mut_);
|
||||||
__state_ = 0;
|
__state_ = 0;
|
||||||
@ -53,7 +53,7 @@ shared_mutex::unlock()
|
|||||||
// Shared ownership
|
// Shared ownership
|
||||||
|
|
||||||
void
|
void
|
||||||
shared_mutex::lock_shared()
|
shared_timed_mutex::lock_shared()
|
||||||
{
|
{
|
||||||
unique_lock<mutex> lk(__mut_);
|
unique_lock<mutex> lk(__mut_);
|
||||||
while ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_)
|
while ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_)
|
||||||
@ -64,7 +64,7 @@ shared_mutex::lock_shared()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
shared_mutex::try_lock_shared()
|
shared_timed_mutex::try_lock_shared()
|
||||||
{
|
{
|
||||||
unique_lock<mutex> lk(__mut_);
|
unique_lock<mutex> lk(__mut_);
|
||||||
unsigned num_readers = __state_ & __n_readers_;
|
unsigned num_readers = __state_ & __n_readers_;
|
||||||
@ -79,7 +79,7 @@ shared_mutex::try_lock_shared()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
shared_mutex::unlock_shared()
|
shared_timed_mutex::unlock_shared()
|
||||||
{
|
{
|
||||||
lock_guard<mutex> _(__mut_);
|
lock_guard<mutex> _(__mut_);
|
||||||
unsigned num_readers = (__state_ & __n_readers_) - 1;
|
unsigned num_readers = (__state_ & __n_readers_) - 1;
|
||||||
|
@ -17,16 +17,16 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m0;
|
std::shared_timed_mutex m0;
|
||||||
std::shared_mutex m1;
|
std::shared_timed_mutex m1;
|
||||||
|
|
||||||
#endif // _LIBCPP_STD_VER > 11
|
#endif // _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
std::shared_lock<std::shared_mutex> lk0(m0);
|
std::shared_lock<std::shared_timed_mutex> lk0(m0);
|
||||||
std::shared_lock<std::shared_mutex> lk1(m1);
|
std::shared_lock<std::shared_timed_mutex> lk1(m1);
|
||||||
lk1 = lk0;
|
lk1 = lk0;
|
||||||
#else
|
#else
|
||||||
# error
|
# error
|
||||||
|
@ -16,14 +16,14 @@
|
|||||||
#include <shared_mutex>
|
#include <shared_mutex>
|
||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
#endif // _LIBCPP_STD_VER > 11
|
#endif // _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
std::shared_lock<std::shared_mutex> lk0(m);
|
std::shared_lock<std::shared_timed_mutex> lk0(m);
|
||||||
std::shared_lock<std::shared_mutex> lk = lk0;
|
std::shared_lock<std::shared_timed_mutex> lk = lk0;
|
||||||
#else
|
#else
|
||||||
# error
|
# error
|
||||||
#endif // _LIBCPP_STD_VER > 11
|
#endif // _LIBCPP_STD_VER > 11
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#if _LIBCPP_STD_VER > 11
|
#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.owns_lock());
|
||||||
assert(ul.mutex() == nullptr);
|
assert(ul.mutex() == nullptr);
|
||||||
#endif // _LIBCPP_STD_VER > 11
|
#endif // _LIBCPP_STD_VER > 11
|
||||||
|
@ -18,16 +18,16 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m0;
|
std::shared_timed_mutex m0;
|
||||||
std::shared_mutex m1;
|
std::shared_timed_mutex m1;
|
||||||
|
|
||||||
#endif // _LIBCPP_STD_VER > 11
|
#endif // _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
std::shared_lock<std::shared_mutex> lk0(m0);
|
std::shared_lock<std::shared_timed_mutex> lk0(m0);
|
||||||
std::shared_lock<std::shared_mutex> lk1(m1);
|
std::shared_lock<std::shared_timed_mutex> lk1(m1);
|
||||||
lk1 = std::move(lk0);
|
lk1 = std::move(lk0);
|
||||||
assert(lk1.mutex() == &m0);
|
assert(lk1.mutex() == &m0);
|
||||||
assert(lk1.owns_lock() == true);
|
assert(lk1.owns_lock() == true);
|
||||||
|
@ -17,14 +17,14 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
#endif // _LIBCPP_STD_VER > 11
|
#endif // _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
std::shared_lock<std::shared_mutex> lk0(m);
|
std::shared_lock<std::shared_timed_mutex> lk0(m);
|
||||||
std::shared_lock<std::shared_mutex> lk = std::move(lk0);
|
std::shared_lock<std::shared_timed_mutex> lk = std::move(lk0);
|
||||||
assert(lk.mutex() == &m);
|
assert(lk.mutex() == &m);
|
||||||
assert(lk.owns_lock() == true);
|
assert(lk.owns_lock() == true);
|
||||||
assert(lk0.mutex() == nullptr);
|
assert(lk0.mutex() == nullptr);
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
|
|
||||||
typedef std::chrono::system_clock Clock;
|
typedef std::chrono::system_clock Clock;
|
||||||
typedef Clock::time_point time_point;
|
typedef Clock::time_point time_point;
|
||||||
@ -34,7 +34,7 @@ void f()
|
|||||||
time_point t0 = Clock::now();
|
time_point t0 = Clock::now();
|
||||||
time_point t1;
|
time_point t1;
|
||||||
{
|
{
|
||||||
std::shared_lock<std::shared_mutex> ul(m);
|
std::shared_lock<std::shared_timed_mutex> ul(m);
|
||||||
t1 = Clock::now();
|
t1 = Clock::now();
|
||||||
}
|
}
|
||||||
ns d = t1 - t0 - ms(250);
|
ns d = t1 - t0 - ms(250);
|
||||||
@ -46,7 +46,7 @@ void g()
|
|||||||
time_point t0 = Clock::now();
|
time_point t0 = Clock::now();
|
||||||
time_point t1;
|
time_point t1;
|
||||||
{
|
{
|
||||||
std::shared_lock<std::shared_mutex> ul(m);
|
std::shared_lock<std::shared_timed_mutex> ul(m);
|
||||||
t1 = Clock::now();
|
t1 = Clock::now();
|
||||||
}
|
}
|
||||||
ns d = t1 - t0;
|
ns d = t1 - t0;
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
m.lock();
|
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.mutex() == &m);
|
||||||
assert(lk.owns_lock() == true);
|
assert(lk.owns_lock() == true);
|
||||||
#endif // _LIBCPP_STD_VER > 11
|
#endif // _LIBCPP_STD_VER > 11
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
std::shared_lock<std::shared_mutex> lk(m, std::defer_lock);
|
std::shared_lock<std::shared_timed_mutex> lk(m, std::defer_lock);
|
||||||
assert(lk.mutex() == &m);
|
assert(lk.mutex() == &m);
|
||||||
assert(lk.owns_lock() == false);
|
assert(lk.owns_lock() == false);
|
||||||
#endif // _LIBCPP_STD_VER > 11
|
#endif // _LIBCPP_STD_VER > 11
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
|
|
||||||
typedef std::chrono::steady_clock Clock;
|
typedef std::chrono::steady_clock Clock;
|
||||||
typedef Clock::time_point time_point;
|
typedef Clock::time_point time_point;
|
||||||
@ -33,7 +33,7 @@ typedef std::chrono::nanoseconds ns;
|
|||||||
void f1()
|
void f1()
|
||||||
{
|
{
|
||||||
time_point t0 = Clock::now();
|
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);
|
assert(lk.owns_lock() == true);
|
||||||
time_point t1 = Clock::now();
|
time_point t1 = Clock::now();
|
||||||
ns d = t1 - t0 - ms(250);
|
ns d = t1 - t0 - ms(250);
|
||||||
@ -43,7 +43,7 @@ void f1()
|
|||||||
void f2()
|
void f2()
|
||||||
{
|
{
|
||||||
time_point t0 = Clock::now();
|
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);
|
assert(lk.owns_lock() == false);
|
||||||
time_point t1 = Clock::now();
|
time_point t1 = Clock::now();
|
||||||
ns d = t1 - t0 - ms(250);
|
ns d = t1 - t0 - ms(250);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
// <shared_mutex>
|
// <shared_mutex>
|
||||||
|
|
||||||
// class shared_mutex;
|
// class shared_timed_mutex;
|
||||||
|
|
||||||
// template <class Clock, class Duration>
|
// template <class Clock, class Duration>
|
||||||
// shared_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
|
// shared_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
|
||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
|
|
||||||
typedef std::chrono::steady_clock Clock;
|
typedef std::chrono::steady_clock Clock;
|
||||||
typedef Clock::time_point time_point;
|
typedef Clock::time_point time_point;
|
||||||
@ -33,7 +33,7 @@ typedef std::chrono::nanoseconds ns;
|
|||||||
void f1()
|
void f1()
|
||||||
{
|
{
|
||||||
time_point t0 = Clock::now();
|
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);
|
assert(lk.owns_lock() == true);
|
||||||
time_point t1 = Clock::now();
|
time_point t1 = Clock::now();
|
||||||
ns d = t1 - t0 - ms(250);
|
ns d = t1 - t0 - ms(250);
|
||||||
@ -43,7 +43,7 @@ void f1()
|
|||||||
void f2()
|
void f2()
|
||||||
{
|
{
|
||||||
time_point t0 = Clock::now();
|
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);
|
assert(lk.owns_lock() == false);
|
||||||
time_point t1 = Clock::now();
|
time_point t1 = Clock::now();
|
||||||
ns d = t1 - t0 - ms(250);
|
ns d = t1 - t0 - ms(250);
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
|
|
||||||
typedef std::chrono::system_clock Clock;
|
typedef std::chrono::system_clock Clock;
|
||||||
typedef Clock::time_point time_point;
|
typedef Clock::time_point time_point;
|
||||||
@ -33,20 +33,20 @@ void f()
|
|||||||
{
|
{
|
||||||
time_point t0 = Clock::now();
|
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);
|
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);
|
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);
|
assert(lk.owns_lock() == false);
|
||||||
}
|
}
|
||||||
while (true)
|
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())
|
if (lk.owns_lock())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
|
|
||||||
typedef std::chrono::system_clock Clock;
|
typedef std::chrono::system_clock Clock;
|
||||||
typedef Clock::time_point time_point;
|
typedef Clock::time_point time_point;
|
||||||
@ -31,7 +31,7 @@ typedef std::chrono::nanoseconds ns;
|
|||||||
|
|
||||||
void f()
|
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();
|
time_point t0 = Clock::now();
|
||||||
lk.lock();
|
lk.lock();
|
||||||
time_point t1 = Clock::now();
|
time_point t1 = Clock::now();
|
||||||
|
@ -18,16 +18,16 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
|
|
||||||
#endif // _LIBCPP_STD_VER > 11
|
#endif // _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
std::shared_lock<std::shared_mutex> lk0;
|
std::shared_lock<std::shared_timed_mutex> lk0;
|
||||||
assert(lk0.mutex() == nullptr);
|
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);
|
assert(lk1.mutex() == &m);
|
||||||
lk1.unlock();
|
lk1.unlock();
|
||||||
assert(lk1.mutex() == &m);
|
assert(lk1.mutex() == &m);
|
||||||
|
@ -18,16 +18,16 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
|
|
||||||
#endif // _LIBCPP_STD_VER > 11
|
#endif // _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#if _LIBCPP_STD_VER > 11
|
#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);
|
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);
|
assert(static_cast<bool>(lk1) == true);
|
||||||
lk1.unlock();
|
lk1.unlock();
|
||||||
assert(static_cast<bool>(lk1) == false);
|
assert(static_cast<bool>(lk1) == false);
|
||||||
|
@ -18,16 +18,16 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
|
|
||||||
#endif // _LIBCPP_STD_VER > 11
|
#endif // _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#if _LIBCPP_STD_VER > 11
|
#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);
|
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);
|
assert(lk1.owns_lock() == true);
|
||||||
lk1.unlock();
|
lk1.unlock();
|
||||||
assert(lk1.owns_lock() == false);
|
assert(lk1.owns_lock() == false);
|
||||||
|
@ -9,17 +9,17 @@
|
|||||||
|
|
||||||
// <shared_mutex>
|
// <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>
|
#include <shared_mutex>
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
std::shared_mutex m0;
|
std::shared_timed_mutex m0;
|
||||||
std::shared_mutex m1;
|
std::shared_timed_mutex m1;
|
||||||
m1 = m0;
|
m1 = m0;
|
||||||
#else
|
#else
|
||||||
# error
|
# error
|
@ -9,17 +9,17 @@
|
|||||||
|
|
||||||
// <shared_mutex>
|
// <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>
|
#include <shared_mutex>
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
std::shared_mutex m0;
|
std::shared_timed_mutex m0;
|
||||||
std::shared_mutex m1(m0);
|
std::shared_timed_mutex m1(m0);
|
||||||
#else
|
#else
|
||||||
# error
|
# error
|
||||||
#endif
|
#endif
|
@ -9,15 +9,15 @@
|
|||||||
|
|
||||||
// <shared_mutex>
|
// <shared_mutex>
|
||||||
|
|
||||||
// class shared_mutex;
|
// class shared_timed_mutex;
|
||||||
|
|
||||||
// shared_mutex();
|
// shared_timed_mutex();
|
||||||
|
|
||||||
#include <shared_mutex>
|
#include <shared_mutex>
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
// <shared_mutex>
|
// <shared_mutex>
|
||||||
|
|
||||||
// class shared_mutex;
|
// class shared_timed_mutex;
|
||||||
|
|
||||||
// void lock();
|
// void lock();
|
||||||
|
|
||||||
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
|
|
||||||
typedef std::chrono::system_clock Clock;
|
typedef std::chrono::system_clock Clock;
|
||||||
typedef Clock::time_point time_point;
|
typedef Clock::time_point time_point;
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
// <shared_mutex>
|
// <shared_mutex>
|
||||||
|
|
||||||
// class shared_mutex;
|
// class shared_timed_mutex;
|
||||||
|
|
||||||
// void lock_shared();
|
// void lock_shared();
|
||||||
|
|
||||||
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
|
|
||||||
typedef std::chrono::system_clock Clock;
|
typedef std::chrono::system_clock Clock;
|
||||||
typedef Clock::time_point time_point;
|
typedef Clock::time_point time_point;
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
// <shared_mutex>
|
// <shared_mutex>
|
||||||
|
|
||||||
// class shared_mutex;
|
// class shared_timed_mutex;
|
||||||
|
|
||||||
// bool try_lock();
|
// bool try_lock();
|
||||||
|
|
||||||
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
|
|
||||||
typedef std::chrono::system_clock Clock;
|
typedef std::chrono::system_clock Clock;
|
||||||
typedef Clock::time_point time_point;
|
typedef Clock::time_point time_point;
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
// <shared_mutex>
|
// <shared_mutex>
|
||||||
|
|
||||||
// class shared_mutex;
|
// class shared_timed_mutex;
|
||||||
|
|
||||||
// template <class Rep, class Period>
|
// template <class Rep, class Period>
|
||||||
// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
|
// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
|
||||||
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
|
|
||||||
typedef std::chrono::steady_clock Clock;
|
typedef std::chrono::steady_clock Clock;
|
||||||
typedef Clock::time_point time_point;
|
typedef Clock::time_point time_point;
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
// <shared_mutex>
|
// <shared_mutex>
|
||||||
|
|
||||||
// class shared_mutex;
|
// class shared_timed_mutex;
|
||||||
|
|
||||||
// bool try_lock_shared();
|
// bool try_lock_shared();
|
||||||
|
|
||||||
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
|
|
||||||
typedef std::chrono::system_clock Clock;
|
typedef std::chrono::system_clock Clock;
|
||||||
typedef Clock::time_point time_point;
|
typedef Clock::time_point time_point;
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
// <shared_mutex>
|
// <shared_mutex>
|
||||||
|
|
||||||
// class shared_mutex;
|
// class shared_timed_mutex;
|
||||||
|
|
||||||
// template <class Rep, class Period>
|
// template <class Rep, class Period>
|
||||||
// bool try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time);
|
// bool try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time);
|
||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
|
|
||||||
typedef std::chrono::steady_clock Clock;
|
typedef std::chrono::steady_clock Clock;
|
||||||
typedef Clock::time_point time_point;
|
typedef Clock::time_point time_point;
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
// <shared_mutex>
|
// <shared_mutex>
|
||||||
|
|
||||||
// class shared_mutex;
|
// class shared_timed_mutex;
|
||||||
|
|
||||||
// template <class Clock, class Duration>
|
// template <class Clock, class Duration>
|
||||||
// bool try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time);
|
// bool try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time);
|
||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
|
|
||||||
typedef std::chrono::steady_clock Clock;
|
typedef std::chrono::steady_clock Clock;
|
||||||
typedef Clock::time_point time_point;
|
typedef Clock::time_point time_point;
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
// <shared_mutex>
|
// <shared_mutex>
|
||||||
|
|
||||||
// class shared_mutex;
|
// class shared_timed_mutex;
|
||||||
|
|
||||||
// template <class Clock, class Duration>
|
// template <class Clock, class Duration>
|
||||||
// bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
|
// bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
|
||||||
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
std::shared_mutex m;
|
std::shared_timed_mutex m;
|
||||||
|
|
||||||
typedef std::chrono::steady_clock Clock;
|
typedef std::chrono::steady_clock Clock;
|
||||||
typedef Clock::time_point time_point;
|
typedef Clock::time_point time_point;
|
@ -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://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/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> -->
|
<!-- <tr><td></td><td></td><td></td><td></td><td></td><td></td></tr> -->
|
||||||
</table>
|
</table>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user