Channel poll methods return Poll instead of bool
This commit is contained in:
parent
b658f10db9
commit
f9d251cd5c
@ -28,7 +28,9 @@ impl<'d> embassy_net_driver::Driver for Driver<'d> {
|
|||||||
type TxToken<'a> = TxToken<'d> where Self: 'a;
|
type TxToken<'a> = TxToken<'d> where Self: 'a;
|
||||||
|
|
||||||
fn receive(&mut self, cx: &mut Context) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)> {
|
fn receive(&mut self, cx: &mut Context) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)> {
|
||||||
if self.runner.rx_channel.poll_ready_to_receive(cx) && self.runner.tx_buf_channel.poll_ready_to_receive(cx) {
|
if self.runner.rx_channel.poll_ready_to_receive(cx).is_ready()
|
||||||
|
&& self.runner.tx_buf_channel.poll_ready_to_receive(cx).is_ready()
|
||||||
|
{
|
||||||
Some((
|
Some((
|
||||||
RxToken {
|
RxToken {
|
||||||
rx: &self.runner.rx_channel,
|
rx: &self.runner.rx_channel,
|
||||||
|
@ -506,14 +506,7 @@ impl<'c, 'd, T: Instance> CanRx<'c, 'd, T> {
|
|||||||
|
|
||||||
/// Waits while receive queue is empty.
|
/// Waits while receive queue is empty.
|
||||||
pub async fn wait_not_empty(&mut self) {
|
pub async fn wait_not_empty(&mut self) {
|
||||||
poll_fn(|cx| {
|
poll_fn(|cx| T::state().rx_queue.poll_ready_to_receive(cx)).await
|
||||||
if T::state().rx_queue.poll_ready_to_receive(cx) {
|
|
||||||
Poll::Ready(())
|
|
||||||
} else {
|
|
||||||
Poll::Pending
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn curr_error(&self) -> Option<BusError> {
|
fn curr_error(&self) -> Option<BusError> {
|
||||||
|
@ -69,7 +69,7 @@ where
|
|||||||
/// Allows a poll_fn to poll until the channel is ready to send
|
/// Allows a poll_fn to poll until the channel is ready to send
|
||||||
///
|
///
|
||||||
/// See [`Channel::poll_ready_to_send()`]
|
/// See [`Channel::poll_ready_to_send()`]
|
||||||
pub fn poll_ready_to_send(&self, cx: &mut Context<'_>) -> bool {
|
pub fn poll_ready_to_send(&self, cx: &mut Context<'_>) -> Poll<()> {
|
||||||
self.channel.poll_ready_to_send(cx)
|
self.channel.poll_ready_to_send(cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ impl<'ch, T> DynamicSender<'ch, T> {
|
|||||||
/// Allows a poll_fn to poll until the channel is ready to send
|
/// Allows a poll_fn to poll until the channel is ready to send
|
||||||
///
|
///
|
||||||
/// See [`Channel::poll_ready_to_send()`]
|
/// See [`Channel::poll_ready_to_send()`]
|
||||||
pub fn poll_ready_to_send(&self, cx: &mut Context<'_>) -> bool {
|
pub fn poll_ready_to_send(&self, cx: &mut Context<'_>) -> Poll<()> {
|
||||||
self.channel.poll_ready_to_send(cx)
|
self.channel.poll_ready_to_send(cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ where
|
|||||||
/// Allows a poll_fn to poll until the channel is ready to receive
|
/// Allows a poll_fn to poll until the channel is ready to receive
|
||||||
///
|
///
|
||||||
/// See [`Channel::poll_ready_to_receive()`]
|
/// See [`Channel::poll_ready_to_receive()`]
|
||||||
pub fn poll_ready_to_receive(&self, cx: &mut Context<'_>) -> bool {
|
pub fn poll_ready_to_receive(&self, cx: &mut Context<'_>) -> Poll<()> {
|
||||||
self.channel.poll_ready_to_receive(cx)
|
self.channel.poll_ready_to_receive(cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,7 +198,7 @@ impl<'ch, T> DynamicReceiver<'ch, T> {
|
|||||||
/// Allows a poll_fn to poll until the channel is ready to receive
|
/// Allows a poll_fn to poll until the channel is ready to receive
|
||||||
///
|
///
|
||||||
/// See [`Channel::poll_ready_to_receive()`]
|
/// See [`Channel::poll_ready_to_receive()`]
|
||||||
pub fn poll_ready_to_receive(&self, cx: &mut Context<'_>) -> bool {
|
pub fn poll_ready_to_receive(&self, cx: &mut Context<'_>) -> Poll<()> {
|
||||||
self.channel.poll_ready_to_receive(cx)
|
self.channel.poll_ready_to_receive(cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,8 +315,8 @@ trait DynamicChannel<T> {
|
|||||||
|
|
||||||
fn try_recv_with_context(&self, cx: Option<&mut Context<'_>>) -> Result<T, TryRecvError>;
|
fn try_recv_with_context(&self, cx: Option<&mut Context<'_>>) -> Result<T, TryRecvError>;
|
||||||
|
|
||||||
fn poll_ready_to_send(&self, cx: &mut Context<'_>) -> bool;
|
fn poll_ready_to_send(&self, cx: &mut Context<'_>) -> Poll<()>;
|
||||||
fn poll_ready_to_receive(&self, cx: &mut Context<'_>) -> bool;
|
fn poll_ready_to_receive(&self, cx: &mut Context<'_>) -> Poll<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error returned by [`try_recv`](Channel::try_recv).
|
/// Error returned by [`try_recv`](Channel::try_recv).
|
||||||
@ -370,10 +370,14 @@ impl<T, const N: usize> ChannelState<T, N> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_ready_to_receive(&mut self, cx: &mut Context<'_>) -> bool {
|
fn poll_ready_to_receive(&mut self, cx: &mut Context<'_>) -> Poll<()> {
|
||||||
self.receiver_waker.register(cx.waker());
|
self.receiver_waker.register(cx.waker());
|
||||||
|
|
||||||
!self.queue.is_empty()
|
if !self.queue.is_empty() {
|
||||||
|
Poll::Ready(())
|
||||||
|
} else {
|
||||||
|
Poll::Pending
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_send(&mut self, message: T) -> Result<(), TrySendError<T>> {
|
fn try_send(&mut self, message: T) -> Result<(), TrySendError<T>> {
|
||||||
@ -395,10 +399,14 @@ impl<T, const N: usize> ChannelState<T, N> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_ready_to_send(&mut self, cx: &mut Context<'_>) -> bool {
|
fn poll_ready_to_send(&mut self, cx: &mut Context<'_>) -> Poll<()> {
|
||||||
self.senders_waker.register(cx.waker());
|
self.senders_waker.register(cx.waker());
|
||||||
|
|
||||||
!self.queue.is_full()
|
if !self.queue.is_full() {
|
||||||
|
Poll::Ready(())
|
||||||
|
} else {
|
||||||
|
Poll::Pending
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,12 +457,12 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Allows a poll_fn to poll until the channel is ready to receive
|
/// Allows a poll_fn to poll until the channel is ready to receive
|
||||||
pub fn poll_ready_to_receive(&self, cx: &mut Context<'_>) -> bool {
|
pub fn poll_ready_to_receive(&self, cx: &mut Context<'_>) -> Poll<()> {
|
||||||
self.lock(|c| c.poll_ready_to_receive(cx))
|
self.lock(|c| c.poll_ready_to_receive(cx))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Allows a poll_fn to poll until the channel is ready to send
|
/// Allows a poll_fn to poll until the channel is ready to send
|
||||||
pub fn poll_ready_to_send(&self, cx: &mut Context<'_>) -> bool {
|
pub fn poll_ready_to_send(&self, cx: &mut Context<'_>) -> Poll<()> {
|
||||||
self.lock(|c| c.poll_ready_to_send(cx))
|
self.lock(|c| c.poll_ready_to_send(cx))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,11 +532,11 @@ where
|
|||||||
Channel::try_recv_with_context(self, cx)
|
Channel::try_recv_with_context(self, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_ready_to_send(&self, cx: &mut Context<'_>) -> bool {
|
fn poll_ready_to_send(&self, cx: &mut Context<'_>) -> Poll<()> {
|
||||||
Channel::poll_ready_to_send(self, cx)
|
Channel::poll_ready_to_send(self, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_ready_to_receive(&self, cx: &mut Context<'_>) -> bool {
|
fn poll_ready_to_receive(&self, cx: &mut Context<'_>) -> Poll<()> {
|
||||||
Channel::poll_ready_to_receive(self, cx)
|
Channel::poll_ready_to_receive(self, cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user