Remove use of deprecated compare_and_swap.

This commit is contained in:
Dario Nieuwenhuis 2020-12-30 01:06:05 +01:00
parent 015b6bbce4
commit bb6f25d010
3 changed files with 8 additions and 4 deletions

View File

@ -150,7 +150,7 @@ pub fn interrupt_take(item: TokenStream) -> TokenStream {
static TAKEN: ::core::sync::atomic::AtomicBool = ::core::sync::atomic::AtomicBool::new(false); static TAKEN: ::core::sync::atomic::AtomicBool = ::core::sync::atomic::AtomicBool::new(false);
if TAKEN.compare_and_swap(false, true, ::core::sync::atomic::Ordering::AcqRel) { if TAKEN.compare_exchange(false, true, ::core::sync::atomic::Ordering::AcqRel, ::core::sync::atomic::Ordering::Acquire).is_err() {
panic!("IRQ Already taken"); panic!("IRQ Already taken");
} }

View File

@ -105,8 +105,8 @@ impl<F: Future + 'static> Task<F> {
if task if task
.header .header
.state .state
.compare_and_swap(0, state, Ordering::AcqRel) .compare_exchange(0, state, Ordering::AcqRel, Ordering::Acquire)
== 0 .is_ok()
{ {
// Initialize the task // Initialize the task
task.header.poll_fn.write(Self::poll); task.header.poll_fn.write(Self::poll);

View File

@ -19,7 +19,11 @@ impl<T> Forever<T> {
} }
pub fn put(&'static self, val: T) -> &'static mut T { pub fn put(&'static self, val: T) -> &'static mut T {
if self.used.compare_and_swap(false, true, Ordering::SeqCst) { if self
.used
.compare_exchange(false, true, Ordering::AcqRel, Ordering::Acquire)
.is_ok()
{
panic!("Forever.put() called multiple times"); panic!("Forever.put() called multiple times");
} }