mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 16:23:10 +00:00
Remove use of deprecated compare_and_swap.
This commit is contained in:
parent
015b6bbce4
commit
bb6f25d010
@ -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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user