From 85ab02b6805ee8b6e80a5ebf96d9a836fdf54a2f Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 17 Jul 2019 16:29:50 +0800 Subject: [PATCH] test/xattr_bench: s/Mutex/ceph::mutex/ Signed-off-by: Kefu Chai --- src/test/xattr_bench.cc | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/test/xattr_bench.cc b/src/test/xattr_bench.cc index eff8b57231c..edbfae25bef 100644 --- a/src/test/xattr_bench.cc +++ b/src/test/xattr_bench.cc @@ -20,9 +20,9 @@ #include "os/filestore/FileStore.h" #include "include/Context.h" #include "common/ceph_argparse.h" -#include "global/global_init.h" -#include "common/Mutex.h" +#include "common/ceph_mutex.h" #include "common/Cond.h" +#include "global/global_init.h" #include #include #include @@ -52,24 +52,24 @@ typename T::iterator rand_choose(T &cont) { class OnApplied : public Context { public: - Mutex *lock; - Cond *cond; + ceph::mutex *lock; + ceph::condition_variable *cond; int *in_progress; ObjectStore::Transaction *t; - OnApplied(Mutex *lock, - Cond *cond, + OnApplied(ceph::mutex *lock, + ceph::condition_variable *cond, int *in_progress, ObjectStore::Transaction *t) : lock(lock), cond(cond), in_progress(in_progress), t(t) { - Mutex::Locker l(*lock); + std::lock_guard l{*lock}; (*in_progress)++; } void finish(int r) override { - Mutex::Locker l(*lock); + std::lock_guard l{*lock}; (*in_progress)--; - cond->Signal(); + cond->notify_all(); } }; @@ -87,8 +87,8 @@ uint64_t do_run(ObjectStore *store, int attrsize, int numattrs, int run, int transsize, int ops, ostream &out) { - Mutex lock("lock"); - Cond cond; + ceph::mutex lock = ceph::make_mutex("lock"); + ceph::condition_variable cond; int in_flight = 0; ObjectStore::Sequencer osr(__func__); ObjectStore::Transaction t; @@ -116,9 +116,8 @@ uint64_t do_run(ObjectStore *store, int attrsize, int numattrs, uint64_t start = get_time(); for (int i = 0; i < ops; ++i) { { - Mutex::Locker l(lock); - while (in_flight >= THREADS) - cond.Wait(lock); + std::unique_lock l{lock}; + cond.wait(l, [&] { in_flight < THREADS; }); } ObjectStore::Transaction *t = new ObjectStore::Transaction; map, ObjectStore::Sequencer*> >::iterator iter = @@ -141,9 +140,8 @@ uint64_t do_run(ObjectStore *store, int attrsize, int numattrs, delete t; } { - Mutex::Locker l(lock); - while (in_flight) - cond.Wait(lock); + std::unique_lock l{lock}; + cond.wait(l, [&] { return in_flight == 0; }); } return get_time() - start; } -- 2.39.5