From: Kefu Chai Date: Thu, 8 Jun 2017 03:18:10 +0000 (+0800) Subject: common/ceph_context: s/atomic_t/std::atomic<>/ X-Git-Tag: v12.1.0~209^2~8 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=fd48d550c0d7aec4f60d5a3153f464b3b584ca12;p=ceph.git common/ceph_context: s/atomic_t/std::atomic<>/ Signed-off-by: Kefu Chai --- diff --git a/src/common/ceph_context.cc b/src/common/ceph_context.cc index ee7641d14c750..dde6854ef327b 100644 --- a/src/common/ceph_context.cc +++ b/src/common/ceph_context.cc @@ -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; diff --git a/src/common/ceph_context.h b/src/common/ceph_context.h index 50e6e554166fe..64aec93f768e4 100644 --- a/src/common/ceph_context.h +++ b/src/common/ceph_context.h @@ -15,12 +15,13 @@ #ifndef CEPH_CEPHCONTEXT_H #define CEPH_CEPHCONTEXT_H +#include #include +#include -#include "include/atomic.h" #include "common/cmdparse.h" #include "crush/CrushLocation.h" -#include +#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 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 void lookup_or_create_singleton_object(T*& p, const std::string &name) {