Skip to content

Commit c3e5603

Browse files
committed
Add compare_and_swap
1 parent bbd8c2f commit c3e5603

File tree

1 file changed

+7
-0
lines changed
  • src/librustc_data_structures

1 file changed

+7
-0
lines changed

src/librustc_data_structures/sync.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ cfg_if! {
100100
}
101101

102102
impl<T: Copy + PartialEq> AtomicCell<T> {
103+
pub fn compare_and_swap(&self, current: T, new: T) -> T {
104+
match self.compare_exchange(current, new) {
105+
Ok(v) => v,
106+
Err(v) => v,
107+
}
108+
}
109+
103110
pub fn compare_exchange(&self,
104111
current: T,
105112
new: T)

0 commit comments

Comments
 (0)