mirror of
https://github.com/ceph/ceph
synced 2024-12-18 09:25:49 +00:00
atomic_t: change cas to compare_and_swap and return bool
Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
This commit is contained in:
parent
5311eb0e5b
commit
72133522c7
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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';
|
||||
|
Loading…
Reference in New Issue
Block a user