summaryrefslogtreecommitdiffstats
path: root/src/test/common/test_shunique_lock.cc
diff options
context:
space:
mode:
authorAdam C. Emerson <aemerson@redhat.com>2017-12-06 21:52:17 +0100
committerAdam C. Emerson <aemerson@redhat.com>2017-12-14 17:40:44 +0100
commite08a1cd88a34b1707596378220db56cdd03f7960 (patch)
tree1bb9bd89f243424d00ef066491ed46ee85501a23 /src/test/common/test_shunique_lock.cc
parentcommon: Get rid of artifact filename (diff)
downloadceph-e08a1cd88a34b1707596378220db56cdd03f7960.tar.xz
ceph-e08a1cd88a34b1707596378220db56cdd03f7960.zip
common: Switch from boost::shared_mutex to std::shared_mutex
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
Diffstat (limited to '')
-rw-r--r--src/test/common/test_shunique_lock.cc109
1 files changed, 54 insertions, 55 deletions
diff --git a/src/test/common/test_shunique_lock.cc b/src/test/common/test_shunique_lock.cc
index 77f9708259d..b7696fe6e85 100644
--- a/src/test/common/test_shunique_lock.cc
+++ b/src/test/common/test_shunique_lock.cc
@@ -14,10 +14,9 @@
#include <future>
#include <mutex>
+#include <shared_mutex>
#include <thread>
-#include <boost/thread/shared_mutex.hpp>
-
#include "common/ceph_time.h"
#include "common/shunique_lock.h"
@@ -45,24 +44,24 @@ static void check_conflicts(SharedMutex sm, AcquireType) {
template<typename SharedMutex>
static void ensure_conflicts(SharedMutex& sm, ceph::acquire_unique_t) {
- auto ttl = &test_try_lock<boost::shared_mutex>;
- auto ttls = &test_try_lock_shared<boost::shared_mutex>;
+ auto ttl = &test_try_lock<std::shared_timed_mutex>;
+ auto ttls = &test_try_lock_shared<std::shared_timed_mutex>;
ASSERT_FALSE(std::async(std::launch::async, ttl, &sm).get());
ASSERT_FALSE(std::async(std::launch::async, ttls, &sm).get());
}
template<typename SharedMutex>
static void ensure_conflicts(SharedMutex& sm, ceph::acquire_shared_t) {
- auto ttl = &test_try_lock<boost::shared_mutex>;
- auto ttls = &test_try_lock_shared<boost::shared_mutex>;
+ auto ttl = &test_try_lock<std::shared_timed_mutex>;
+ auto ttls = &test_try_lock_shared<std::shared_timed_mutex>;
ASSERT_FALSE(std::async(std::launch::async, ttl, &sm).get());
ASSERT_TRUE(std::async(std::launch::async, ttls, &sm).get());
}
template<typename SharedMutex>
static void ensure_free(SharedMutex& sm) {
- auto ttl = &test_try_lock<boost::shared_mutex>;
- auto ttls = &test_try_lock_shared<boost::shared_mutex>;
+ auto ttl = &test_try_lock<std::shared_timed_mutex>;
+ auto ttls = &test_try_lock_shared<std::shared_timed_mutex>;
ASSERT_TRUE(std::async(std::launch::async, ttl, &sm).get());
ASSERT_TRUE(std::async(std::launch::async, ttls, &sm).get());
}
@@ -108,7 +107,7 @@ static void check_abjures_lock(const ceph::shunique_lock<SharedMutex>& sul) {
}
TEST(ShuniqueLock, DefaultConstructor) {
- typedef ceph::shunique_lock<boost::shared_mutex> shunique_lock;
+ typedef ceph::shunique_lock<std::shared_timed_mutex> shunique_lock;
shunique_lock l;
@@ -138,8 +137,8 @@ TEST(ShuniqueLock, DefaultConstructor) {
template<typename AcquireType>
void lock_unlock(AcquireType at) {
- boost::shared_mutex sm;
- typedef ceph::shunique_lock<boost::shared_mutex> shunique_lock;
+ std::shared_timed_mutex sm;
+ typedef ceph::shunique_lock<std::shared_timed_mutex> shunique_lock;
shunique_lock l(sm, at);
@@ -164,8 +163,8 @@ TEST(ShuniqueLock, LockUnlock) {
template<typename AcquireType>
void lock_destruct(AcquireType at) {
- boost::shared_mutex sm;
- typedef ceph::shunique_lock<boost::shared_mutex> shunique_lock;
+ std::shared_timed_mutex sm;
+ typedef ceph::shunique_lock<std::shared_timed_mutex> shunique_lock;
{
shunique_lock l(sm, at);
@@ -184,9 +183,9 @@ TEST(ShuniqueLock, LockDestruct) {
template<typename AcquireType>
void move_construct(AcquireType at) {
- boost::shared_mutex sm;
+ std::shared_timed_mutex sm;
- typedef ceph::shunique_lock<boost::shared_mutex> shunique_lock;
+ typedef ceph::shunique_lock<std::shared_timed_mutex> shunique_lock;
{
shunique_lock l(sm, at);
@@ -219,45 +218,45 @@ TEST(ShuniqueLock, MoveConstruct) {
move_construct(ceph::acquire_unique);
move_construct(ceph::acquire_shared);
- boost::shared_mutex sm;
+ std::shared_timed_mutex sm;
{
- std::unique_lock<boost::shared_mutex> ul(sm);
+ std::unique_lock<std::shared_timed_mutex> ul(sm);
ensure_conflicts(sm, ceph::acquire_unique);
- ceph::shunique_lock<boost::shared_mutex> l(std::move(ul));
+ ceph::shunique_lock<std::shared_timed_mutex> l(std::move(ul));
check_owns_lock(sm, l, ceph::acquire_unique);
ensure_conflicts(sm, ceph::acquire_unique);
}
{
- std::unique_lock<boost::shared_mutex> ul(sm, std::defer_lock);
+ std::unique_lock<std::shared_timed_mutex> ul(sm, std::defer_lock);
ensure_free(sm);
- ceph::shunique_lock<boost::shared_mutex> l(std::move(ul));
+ ceph::shunique_lock<std::shared_timed_mutex> l(std::move(ul));
check_abjures_lock(sm, l);
ensure_free(sm);
}
{
- std::unique_lock<boost::shared_mutex> ul;
- ceph::shunique_lock<boost::shared_mutex> l(std::move(ul));
+ std::unique_lock<std::shared_timed_mutex> ul;
+ ceph::shunique_lock<std::shared_timed_mutex> l(std::move(ul));
check_abjures_lock(l);
}
{
- boost::shared_lock<boost::shared_mutex> sl(sm);
+ std::shared_lock<std::shared_timed_mutex> sl(sm);
ensure_conflicts(sm, ceph::acquire_shared);
- ceph::shunique_lock<boost::shared_mutex> l(std::move(sl));
+ ceph::shunique_lock<std::shared_timed_mutex> l(std::move(sl));
check_owns_lock(sm, l, ceph::acquire_shared);
ensure_conflicts(sm, ceph::acquire_shared);
}
{
- boost::shared_lock<boost::shared_mutex> sl;
- ceph::shunique_lock<boost::shared_mutex> l(std::move(sl));
+ std::shared_lock<std::shared_timed_mutex> sl;
+ ceph::shunique_lock<std::shared_timed_mutex> l(std::move(sl));
check_abjures_lock(l);
}
}
template<typename AcquireType>
void move_assign(AcquireType at) {
- boost::shared_mutex sm;
+ std::shared_timed_mutex sm;
- typedef ceph::shunique_lock<boost::shared_mutex> shunique_lock;
+ typedef ceph::shunique_lock<std::shared_timed_mutex> shunique_lock;
{
shunique_lock l(sm, at);
@@ -298,40 +297,40 @@ TEST(ShuniqueLock, MoveAssign) {
move_assign(ceph::acquire_unique);
move_assign(ceph::acquire_shared);
- boost::shared_mutex sm;
+ std::shared_timed_mutex sm;
{
- std::unique_lock<boost::shared_mutex> ul(sm);
+ std::unique_lock<std::shared_timed_mutex> ul(sm);
ensure_conflicts(sm, ceph::acquire_unique);
- ceph::shunique_lock<boost::shared_mutex> l;
+ ceph::shunique_lock<std::shared_timed_mutex> l;
l = std::move(ul);
check_owns_lock(sm, l, ceph::acquire_unique);
ensure_conflicts(sm, ceph::acquire_unique);
}
{
- std::unique_lock<boost::shared_mutex> ul(sm, std::defer_lock);
+ std::unique_lock<std::shared_timed_mutex> ul(sm, std::defer_lock);
ensure_free(sm);
- ceph::shunique_lock<boost::shared_mutex> l;
+ ceph::shunique_lock<std::shared_timed_mutex> l;
l = std::move(ul);
check_abjures_lock(sm, l);
ensure_free(sm);
}
{
- std::unique_lock<boost::shared_mutex> ul;
- ceph::shunique_lock<boost::shared_mutex> l;
+ std::unique_lock<std::shared_timed_mutex> ul;
+ ceph::shunique_lock<std::shared_timed_mutex> l;
l = std::move(ul);
check_abjures_lock(l);
}
{
- boost::shared_lock<boost::shared_mutex> sl(sm);
+ std::shared_lock<std::shared_timed_mutex> sl(sm);
ensure_conflicts(sm, ceph::acquire_shared);
- ceph::shunique_lock<boost::shared_mutex> l;
+ ceph::shunique_lock<std::shared_timed_mutex> l;
l = std::move(sl);
check_owns_lock(sm, l, ceph::acquire_shared);
ensure_conflicts(sm, ceph::acquire_shared);
}
{
- boost::shared_lock<boost::shared_mutex> sl;
- ceph::shunique_lock<boost::shared_mutex> l;
+ std::shared_lock<std::shared_timed_mutex> sl;
+ ceph::shunique_lock<std::shared_timed_mutex> l;
l = std::move(sl);
check_abjures_lock(l);
}
@@ -340,9 +339,9 @@ TEST(ShuniqueLock, MoveAssign) {
template<typename AcquireType>
void construct_deferred(AcquireType at) {
- boost::shared_mutex sm;
+ std::shared_timed_mutex sm;
- typedef ceph::shunique_lock<boost::shared_mutex> shunique_lock;
+ typedef ceph::shunique_lock<std::shared_timed_mutex> shunique_lock;
{
shunique_lock l(sm, std::defer_lock);
@@ -379,8 +378,8 @@ TEST(ShuniqueLock, ConstructDeferred) {
template<typename AcquireType>
void construct_try(AcquireType at) {
- boost::shared_mutex sm;
- typedef ceph::shunique_lock<boost::shared_mutex> shunique_lock;
+ std::shared_timed_mutex sm;
+ typedef ceph::shunique_lock<std::shared_timed_mutex> shunique_lock;
{
shunique_lock l(sm, at, std::try_to_lock);
@@ -389,7 +388,7 @@ void construct_try(AcquireType at) {
}
{
- std::unique_lock<boost::shared_mutex> l(sm);
+ std::unique_lock<std::shared_timed_mutex> l(sm);
ensure_conflicts(sm, ceph::acquire_unique);
std::async(std::launch::async, [&sm, at]() {
@@ -415,9 +414,9 @@ TEST(ShuniqueLock, ConstructTry) {
template<typename AcquireType>
void construct_adopt(AcquireType at) {
- boost::shared_mutex sm;
+ std::shared_timed_mutex sm;
- typedef ceph::shunique_lock<boost::shared_mutex> shunique_lock;
+ typedef ceph::shunique_lock<std::shared_timed_mutex> shunique_lock;
{
shunique_lock d(sm, at);
@@ -442,9 +441,9 @@ TEST(ShuniqueLock, ConstructAdopt) {
template<typename AcquireType>
void try_lock(AcquireType at) {
- boost::shared_mutex sm;
+ std::shared_timed_mutex sm;
- typedef ceph::shunique_lock<boost::shared_mutex> shunique_lock;
+ typedef ceph::shunique_lock<std::shared_timed_mutex> shunique_lock;
{
shunique_lock l(sm, std::defer_lock);
@@ -455,7 +454,7 @@ void try_lock(AcquireType at) {
}
{
- std::unique_lock<boost::shared_mutex> l(sm);
+ std::unique_lock<std::shared_timed_mutex> l(sm);
std::async(std::launch::async, [&sm, at]() {
shunique_lock l(sm, std::defer_lock);
@@ -483,8 +482,8 @@ TEST(ShuniqueLock, TryLock) {
}
TEST(ShuniqueLock, Release) {
- boost::shared_mutex sm;
- typedef ceph::shunique_lock<boost::shared_mutex> shunique_lock;
+ std::shared_timed_mutex sm;
+ typedef ceph::shunique_lock<std::shared_timed_mutex> shunique_lock;
{
shunique_lock l(sm, ceph::acquire_unique);
@@ -528,7 +527,7 @@ TEST(ShuniqueLock, Release) {
ensure_free(sm);
{
- std::unique_lock<boost::shared_mutex> ul;
+ std::unique_lock<std::shared_timed_mutex> ul;
shunique_lock l(sm, std::defer_lock);
check_abjures_lock(sm, l);
ensure_free(sm);
@@ -542,7 +541,7 @@ TEST(ShuniqueLock, Release) {
ensure_free(sm);
{
- std::unique_lock<boost::shared_mutex> ul;
+ std::unique_lock<std::shared_timed_mutex> ul;
shunique_lock l;
check_abjures_lock(l);
@@ -554,9 +553,9 @@ TEST(ShuniqueLock, Release) {
}
TEST(ShuniqueLock, NoRecursion) {
- boost::shared_mutex sm;
+ std::shared_timed_mutex sm;
- typedef ceph::shunique_lock<boost::shared_mutex> shunique_lock;
+ typedef ceph::shunique_lock<std::shared_timed_mutex> shunique_lock;
{
shunique_lock l(sm, ceph::acquire_unique);