]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
messenger: migrate atomic_t to std::atomic<>
authorJesse Williamson <jwilliamson@suse.de>
Tue, 2 May 2017 16:27:12 +0000 (09:27 -0700)
committerJesse Williamson <jwilliamson@suse.de>
Sun, 28 May 2017 15:48:15 +0000 (08:48 -0700)
Signed-off-by: Jesse Williamson <jwilliamson@suse.de>
src/msg/simple/Pipe.h
src/msg/simple/SimpleMessenger.h
src/msg/xio/XioConnection.h

index 5324c108d55c614ffeacb59fe60f8245dad1f930..9dd00d1b48f345f0d4782798516c300246db14a0 100644 (file)
@@ -129,7 +129,7 @@ static const int SM_IOV_MAX = (IOV_MAX >= 1024 ? IOV_MAX / 4 : IOV_MAX);
     
     Mutex pipe_lock;
     int state;
-    atomic_t state_closed; // non-zero iff state = STATE_CLOSED
+    std::atomic<bool> state_closed = { false }; // true iff state = STATE_CLOSED
 
     // session_security handles any signatures or encryptions required for this pipe's msgs. PLR
 
index 9c5f43e89ba83e226da20bc3f3177dc89cb659e6..de546e24f43928f90aa65de2537279da21e47e1a 100644 (file)
@@ -322,7 +322,7 @@ private:
     if (p == rank_pipe.end())
       return NULL;
     // see lock cribbing in Pipe::fault()
-    if (p->second->state_closed.read())
+    if (p->second->state_closed)
       return NULL;
     return p->second;
   }
index ce166794077182de312cd120348e864d605a82ab..cb1d735b10c73030a326cd72bd88c7301d2ac7ef 100644 (file)
@@ -140,7 +140,7 @@ private:
     uint32_t reconnects;
     uint32_t connect_seq, global_seq, peer_global_seq;
     uint64_t in_seq, out_seq_acked; // atomic<uint64_t>, got receipt
-    atomic64_t out_seq; // atomic<uint64_t>
+    std::atomic<uint64_t> out_seq; 
 
     uint32_t flags;
 
@@ -161,11 +161,11 @@ private:
        flags(FLAG_NONE) {}
 
     uint64_t get_session_state() {
-      return session_state.read();
+      return session_state;
     }
 
     uint64_t get_startup_state() {
-      return startup_state.read();
+      return startup_state;
     }
 
     void set_in_seq(uint64_t seq) {
@@ -173,7 +173,7 @@ private:
     }
 
     uint64_t next_out_seq() {
-      return out_seq.inc();
+      return ++out_seq;
     };
 
     // state machine
@@ -274,7 +274,7 @@ public:
   }
   ostream& conn_prefix(std::ostream *_dout);
 
-  bool is_connected() override { return connected.read(); }
+  bool is_connected() override { return connected; }
 
   int send_message(Message *m) override;
   void send_keepalive() override {send_keepalive_or_ack();}
@@ -288,8 +288,7 @@ public:
 
   XioConnection* get() {
 #if 0
-    int refs = nref.read();
-    cout << "XioConnection::get " << this << " " << refs << std::endl;
+    cout << "XioConnection::get " << this << " " << nref.load() << std::endl;
 #endif
     RefCountedObject::get();
     return this;
@@ -298,8 +297,7 @@ public:
   void put() {
     RefCountedObject::put();
 #if 0
-    int refs = nref.read();
-    cout << "XioConnection::put " << this << " " << refs << std::endl;
+    cout << "XioConnection::put " << this << " " << nref.load() << std::endl;
 #endif
   }
 
@@ -340,9 +338,9 @@ typedef boost::intrusive_ptr<XioConnection> XioConnectionRef;
 class XioLoopbackConnection : public Connection
 {
 private:
-  atomic64_t seq;
+  std::atomic<uint64_t> seq = { 0 };
 public:
-  explicit XioLoopbackConnection(Messenger *m) : Connection(m->cct, m), seq(0)
+  explicit XioLoopbackConnection(Messenger *m) : Connection(m->cct, m)
     {
       const entity_inst_t& m_inst = m->get_myinst();
       peer_addr = m_inst.addr;
@@ -362,7 +360,7 @@ public:
   void mark_disposable() override {}
 
   uint64_t get_seq() {
-    return seq.read();
+    return seq;
   }
 
   uint64_t next_seq() {