Desugar some async fns

This commit is contained in:
Dániel Buga
2024-12-30 12:13:13 +01:00
parent a4f8fddd69
commit 44217aa092
18 changed files with 103 additions and 124 deletions

View File

@@ -1,7 +1,7 @@
//! CDC-ACM class implementation, aka Serial over USB.
use core::cell::{Cell, RefCell};
use core::future::poll_fn;
use core::future::{poll_fn, Future};
use core::mem::{self, MaybeUninit};
use core::sync::atomic::{AtomicBool, Ordering};
use core::task::Poll;
@@ -108,7 +108,7 @@ impl Default for ControlShared {
}
impl ControlShared {
async fn changed(&self) {
fn changed(&self) -> impl Future<Output = ()> + '_ {
poll_fn(|cx| {
if self.changed.load(Ordering::Relaxed) {
self.changed.store(false, Ordering::Relaxed);
@@ -118,7 +118,6 @@ impl ControlShared {
Poll::Pending
}
})
.await;
}
}

View File

@@ -11,7 +11,7 @@
//! The class provides volume and mute controls for each channel.
use core::cell::{Cell, RefCell};
use core::future::poll_fn;
use core::future::{poll_fn, Future};
use core::marker::PhantomData;
use core::sync::atomic::{AtomicBool, AtomicU32, Ordering};
use core::task::Poll;
@@ -389,7 +389,7 @@ impl<'d> Default for SharedControl<'d> {
}
impl<'d> SharedControl<'d> {
async fn changed(&self) {
fn changed(&self) -> impl Future<Output = ()> + '_ {
poll_fn(|context| {
if self.changed.load(Ordering::Relaxed) {
self.changed.store(false, Ordering::Relaxed);
@@ -399,7 +399,6 @@ impl<'d> SharedControl<'d> {
Poll::Pending
}
})
.await;
}
}