]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/ceph_context: s/atomic_t/std::atomic<>/
authorKefu Chai <kchai@redhat.com>
Thu, 8 Jun 2017 03:18:10 +0000 (11:18 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 8 Jun 2017 03:23:13 +0000 (11:23 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/ceph_context.cc
src/common/ceph_context.h

index ee7641d14c750d4f973978d127f183ddc24ed67b..dde6854ef327bbcee8903fd55063d7d93893d529 100644 (file)
@@ -27,6 +27,7 @@
 #include "include/str_list.h"
 #include "common/PluginRegistry.h"
 
+using ceph::bufferlist;
 using ceph::HeartbeatMap;
 
 namespace {
@@ -682,7 +683,7 @@ CephContext::~CephContext()
 }
 
 void CephContext::put() {
-  if (nref.dec() == 0) {
+  if (--nref == 0) {
     ANNOTATE_HAPPENS_AFTER(&nref);
     ANNOTATE_HAPPENS_BEFORE_FORGET_ALL(&nref);
     delete this;
index 50e6e554166fe88947c7888a56fc93b9433f687e..64aec93f768e4d39c08db6540a52ede193f2e18a 100644 (file)
 #ifndef CEPH_CEPHCONTEXT_H
 #define CEPH_CEPHCONTEXT_H
 
+#include <atomic>
 #include <set>
+#include <boost/noncopyable.hpp>
 
-#include "include/atomic.h"
 #include "common/cmdparse.h"
 #include "crush/CrushLocation.h"
-#include <boost/noncopyable.hpp>
+#include "include/Spinlock.h"
 
 class AdminSocket;
 class CephContextServiceThread;
@@ -40,8 +41,6 @@ namespace ceph {
   }
 }
 
-using ceph::bufferlist;
-
 /* A CephContext represents the context held by a single library user.
  * There can be multiple CephContexts in the same process.
  *
@@ -56,10 +55,10 @@ public:
   // ref count!
 private:
   ~CephContext();
-  atomic_t nref;
+  std::atomic<unsigned> nref;
 public:
   CephContext *get() {
-    nref.inc();
+    ++nref;
     return this;
   }
   void put();
@@ -119,7 +118,7 @@ public:
    * process an admin socket command
    */
   void do_command(std::string command, cmdmap_t& cmdmap, std::string format,
-                 bufferlist *out);
+                 ceph::bufferlist *out);
 
   template<typename T>
   void lookup_or_create_singleton_object(T*& p, const std::string &name) {