]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
atomic_t: change cas to compare_and_swap and return bool 4511/head
authorHaomai Wang <haomaiwang@gmail.com>
Fri, 1 May 2015 17:43:49 +0000 (01:43 +0800)
committerHaomai Wang <haomaiwang@gmail.com>
Fri, 1 May 2015 19:02:31 +0000 (03:02 +0800)
Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
src/include/atomic.h
src/msg/async/Event.cc

index 7fcfb311c13fb8308715b240357775e06c6651c1..d5bc1c722d019819287d6b2fc116e094cb7e35d3 100644 (file)
@@ -70,11 +70,11 @@ namespace ceph {
       ceph_spin_unlock(&lock);
       return ret;
     }
-    int cas(T o, T n) {
-      int success = 0;
+    bool compare_and_swap(T o, T n) {
+      bool success = false;
       ceph_spin_lock(&lock);
       if (val == o) {
-        success = 1;
+        success = true;
         val = n;
       }
       ceph_spin_unlock(&lock);
@@ -124,7 +124,7 @@ namespace ceph {
       // at some point.  this hack can go away someday...
       return AO_load_full((AO_t *)&val);
     }
-    int cas(AO_t o, AO_t n) {
+    bool compare_and_swap(AO_t o, AO_t n) {
       return AO_compare_and_swap(&val, o, n);
     }
 
index daa5fb1b191261fe60fc1f12aed935a2968c27cf..4b63209078f00c51effb4145aefef1a88269ff50 100644 (file)
@@ -246,7 +246,7 @@ void EventCenter::delete_time_event(uint64_t id)
 
 void EventCenter::wakeup()
 {
-  if (already_wakeup.cas(0, 1)) {
+  if (already_wakeup.compare_and_swap(0, 1)) {
     ldout(cct, 1) << __func__ << dendl;
     char buf[1];
     buf[0] = 'c';