]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/ceph_context: Mutex -> ceph::mutex
authorSage Weil <sage@redhat.com>
Tue, 16 Oct 2018 14:10:47 +0000 (09:10 -0500)
committerKefu Chai <kchai@redhat.com>
Wed, 21 Nov 2018 03:56:32 +0000 (11:56 +0800)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/ceph_context.cc

index 025799dc314d9148ed3b9a5c5ee85e9fd06c3f05..d5f4c02a4ff73eae3541b4394f77c9dc439c27f3 100644 (file)
@@ -25,7 +25,8 @@
 #include "include/mempool.h"
 #include "common/admin_socket.h"
 #include "common/code_environment.h"
-#include "common/Cond.h"
+#include "common/ceph_mutex.h"
+#include "common/debug.h"
 #include "common/config.h"
 #include "common/ceph_crypto.h"
 #include "common/HeartbeatMap.h"
@@ -174,8 +175,7 @@ class CephContextServiceThread : public Thread
 {
 public:
   explicit CephContextServiceThread(CephContext *cct)
-    : _lock("CephContextServiceThread::_lock"),
-      _reopen_logs(false), _exit_thread(false), _cct(cct)
+    : _reopen_logs(false), _exit_thread(false), _cct(cct)
   {
   }
 
@@ -184,13 +184,13 @@ public:
   void *entry() override
   {
     while (1) {
-      std::lock_guard<Mutex> l(_lock);
+      std::unique_lock l(_lock);
 
       if (_cct->_conf->heartbeat_interval) {
-        utime_t interval(_cct->_conf->heartbeat_interval, 0);
-        _cond.WaitInterval(_lock, interval);
+        auto interval = ceph::make_timespan(_cct->_conf->heartbeat_interval);
+        _cond.wait_for(l, interval);
       } else
-        _cond.Wait(_lock);
+        _cond.wait(l);
 
       if (_exit_thread) {
         break;
@@ -210,21 +210,21 @@ public:
 
   void reopen_logs()
   {
-    std::lock_guard<Mutex> l(_lock);
+    std::lock_guard l(_lock);
     _reopen_logs = true;
-    _cond.Signal();
+    _cond.notify_all();
   }
 
   void exit_thread()
   {
-    std::lock_guard<Mutex> l(_lock);
+    std::lock_guard l(_lock);
     _exit_thread = true;
-    _cond.Signal();
+    _cond.notify_all();
   }
 
 private:
-  Mutex _lock;
-  Cond _cond;
+  ceph::mutex _lock = ceph::make_mutex("CephContextServiceThread::_lock");
+  ceph::condition_variable _cond;
   bool _reopen_logs;
   bool _exit_thread;
   CephContext *_cct;