atomic_t: change cas to compare_and_swap and return bool

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
This commit is contained in:
Haomai Wang 2015-05-02 01:43:49 +08:00
parent 5311eb0e5b
commit 72133522c7
2 changed files with 5 additions and 5 deletions

View 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);
}

View 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';