]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/rgw: s/Mutex/ceph::mutex/
authorKefu Chai <kchai@redhat.com>
Sun, 7 Jul 2019 03:18:41 +0000 (11:18 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 3 Aug 2019 03:27:19 +0000 (11:27 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/cls/rgw/cls_rgw_client.cc
src/cls/rgw/cls_rgw_client.h

index 97426ed7661747bf8e788e15f30ae8656fa77a25..cb6256d246d426ed1b69ac93b4daa3dd56b97f9c 100644 (file)
@@ -40,7 +40,7 @@ public:
 };
 
 void BucketIndexAioManager::do_completion(int id) {
-  Mutex::Locker l(lock);
+  std::lock_guard l{lock};
 
   map<int, librados::AioCompletion*>::iterator iter = pendings.find(id);
   ceph_assert(iter != pendings.end());
@@ -55,20 +55,19 @@ void BucketIndexAioManager::do_completion(int id) {
     pending_objs.erase(miter);
   }
 
-  cond.Signal();
+  cond.notify_all();
 }
 
 bool BucketIndexAioManager::wait_for_completions(int valid_ret_code,
     int *num_completions, int *ret_code, map<int, string> *objs) {
-  lock.Lock();
+  std::unique_lock locker{lock};
   if (pendings.empty() && completions.empty()) {
-    lock.Unlock();
     return false;
   }
 
   if (completions.empty()) {
     // Wait for AIO completion
-    cond.Wait(lock);
+    cond.wait(locker);
   }
 
   // Clear the completed AIOs
@@ -88,7 +87,6 @@ bool BucketIndexAioManager::wait_for_completions(int valid_ret_code,
   if (num_completions)
     (*num_completions) = completions.size();
   completions.clear();
-  lock.Unlock();
 
   return true;
 }
index b090fbd74787f18af0ee8c2ba8c66dfae2bd00c3..8def8826e549b499490cdd8dab13ca5dead643ac 100644 (file)
@@ -11,8 +11,7 @@
 #include "common/RefCountedObj.h"
 #include "include/compat.h"
 #include "common/ceph_time.h"
-#include "common/Mutex.h"
-#include "common/Cond.h"
+#include "common/ceph_mutex.h"
 
 // Forward declaration
 class BucketIndexAioManager;
@@ -38,9 +37,9 @@ private:
   map<int, librados::AioCompletion*> completions;
   map<int, string> pending_objs;
   map<int, string> completion_objs;
-  int next;
-  Mutex lock;
-  Cond cond;
+  int next = 0;
+  ceph::mutex lock = ceph::make_mutex("BucketIndexAioManager::lock");
+  ceph::condition_variable cond;
   /*
    * Callback implementation for AIO request.
    */
@@ -73,8 +72,7 @@ public:
   /*
    * Create a new instance.
    */
-  BucketIndexAioManager() : next(0), lock("BucketIndexAioManager::lock") {}
-
+  BucketIndexAioManager() = default;
 
   /*
    * Do completion for the given AIO request.
@@ -98,7 +96,7 @@ public:
    * Do aio read operation.
    */
   bool aio_operate(librados::IoCtx& io_ctx, const string& oid, librados::ObjectReadOperation *op) {
-    Mutex::Locker l(lock);
+    std::lock_guard l{lock};
     BucketIndexAioArg *arg = new BucketIndexAioArg(get_next(), this);
     librados::AioCompletion *c = librados::Rados::aio_create_completion((void*)arg, NULL, bucket_index_op_completion_cb);
     int r = io_ctx.aio_operate(oid, c, (librados::ObjectReadOperation*)op, NULL);
@@ -114,7 +112,7 @@ public:
    * Do aio write operation.
    */
   bool aio_operate(librados::IoCtx& io_ctx, const string& oid, librados::ObjectWriteOperation *op) {
-    Mutex::Locker l(lock);
+    std::lock_guard l{lock};
     BucketIndexAioArg *arg = new BucketIndexAioArg(get_next(), this);
     librados::AioCompletion *c = librados::Rados::aio_create_completion((void*)arg, NULL, bucket_index_op_completion_cb);
     int r = io_ctx.aio_operate(oid, c, (librados::ObjectWriteOperation*)op);