From 1eb03dc41a4a5fa8435f9a49d26e29ceea6d498e Mon Sep 17 00:00:00 2001 From: Ruben De Smet Date: Fri, 11 Aug 2023 12:07:30 +0200 Subject: [PATCH] Prefer `receive` over `recv` --- embassy-net-driver-channel/src/lib.rs | 22 +++++++++++----------- embassy-sync/src/zero_copy_channel.rs | 18 +++++++++--------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/embassy-net-driver-channel/src/lib.rs b/embassy-net-driver-channel/src/lib.rs index e8cd66f8..a2076074 100644 --- a/embassy-net-driver-channel/src/lib.rs +++ b/embassy-net-driver-channel/src/lib.rs @@ -131,24 +131,24 @@ impl<'d, const MTU: usize> Runner<'d, MTU> { } pub async fn tx_buf(&mut self) -> &mut [u8] { - let p = self.tx_chan.recv().await; + let p = self.tx_chan.receive().await; &mut p.buf[..p.len] } pub fn try_tx_buf(&mut self) -> Option<&mut [u8]> { - let p = self.tx_chan.try_recv()?; + let p = self.tx_chan.try_receive()?; Some(&mut p.buf[..p.len]) } pub fn poll_tx_buf(&mut self, cx: &mut Context) -> Poll<&mut [u8]> { - match self.tx_chan.poll_recv(cx) { + match self.tx_chan.poll_receive(cx) { Poll::Ready(p) => Poll::Ready(&mut p.buf[..p.len]), Poll::Pending => Poll::Pending, } } pub fn tx_done(&mut self) { - self.tx_chan.recv_done(); + self.tx_chan.receive_done(); } } @@ -205,24 +205,24 @@ impl<'d, const MTU: usize> RxRunner<'d, MTU> { impl<'d, const MTU: usize> TxRunner<'d, MTU> { pub async fn tx_buf(&mut self) -> &mut [u8] { - let p = self.tx_chan.recv().await; + let p = self.tx_chan.receive().await; &mut p.buf[..p.len] } pub fn try_tx_buf(&mut self) -> Option<&mut [u8]> { - let p = self.tx_chan.try_recv()?; + let p = self.tx_chan.try_receive()?; Some(&mut p.buf[..p.len]) } pub fn poll_tx_buf(&mut self, cx: &mut Context) -> Poll<&mut [u8]> { - match self.tx_chan.poll_recv(cx) { + match self.tx_chan.poll_receive(cx) { Poll::Ready(p) => Poll::Ready(&mut p.buf[..p.len]), Poll::Pending => Poll::Pending, } } pub fn tx_done(&mut self) { - self.tx_chan.recv_done(); + self.tx_chan.receive_done(); } } @@ -294,7 +294,7 @@ impl<'d, const MTU: usize> embassy_net_driver::Driver for Device<'d, MTU> { type TxToken<'a> = TxToken<'a, MTU> where Self: 'a ; fn receive(&mut self, cx: &mut Context) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)> { - if self.rx.poll_recv(cx).is_ready() && self.tx.poll_send(cx).is_ready() { + if self.rx.poll_receive(cx).is_ready() && self.tx.poll_send(cx).is_ready() { Some((RxToken { rx: self.rx.borrow() }, TxToken { tx: self.tx.borrow() })) } else { None @@ -338,9 +338,9 @@ impl<'a, const MTU: usize> embassy_net_driver::RxToken for RxToken<'a, MTU> { F: FnOnce(&mut [u8]) -> R, { // NOTE(unwrap): we checked the queue wasn't full when creating the token. - let pkt = unwrap!(self.rx.try_recv()); + let pkt = unwrap!(self.rx.try_receive()); let r = f(&mut pkt.buf[..pkt.len]); - self.rx.recv_done(); + self.rx.receive_done(); r } } diff --git a/embassy-sync/src/zero_copy_channel.rs b/embassy-sync/src/zero_copy_channel.rs index 3701ccf1..cbb8cb52 100644 --- a/embassy-sync/src/zero_copy_channel.rs +++ b/embassy-sync/src/zero_copy_channel.rs @@ -27,7 +27,7 @@ impl<'a, M: RawMutex, T> Channel<'a, M, T> { back: 0, full: false, send_waker: WakerRegistration::new(), - recv_waker: WakerRegistration::new(), + receive_waker: WakerRegistration::new(), })), } } @@ -62,7 +62,7 @@ impl<'a, M: RawMutex, T> Sender<'a, M, T> { match s.push_index() { Some(i) => Poll::Ready(unsafe { &mut *self.channel.buf.add(i) }), None => { - s.recv_waker.register(cx.waker()); + s.receive_waker.register(cx.waker()); Poll::Pending } } @@ -76,7 +76,7 @@ impl<'a, M: RawMutex, T> Sender<'a, M, T> { match s.push_index() { Some(i) => Poll::Ready(i), None => { - s.recv_waker.register(cx.waker()); + s.receive_waker.register(cx.waker()); Poll::Pending } } @@ -99,7 +99,7 @@ impl<'a, M: RawMutex, T> Receiver<'a, M, T> { Receiver { channel: self.channel } } - pub fn try_recv(&mut self) -> Option<&mut T> { + pub fn try_receive(&mut self) -> Option<&mut T> { self.channel.state.lock(|s| { let s = &mut *s.borrow_mut(); match s.pop_index() { @@ -109,7 +109,7 @@ impl<'a, M: RawMutex, T> Receiver<'a, M, T> { }) } - pub fn poll_recv(&mut self, cx: &mut Context) -> Poll<&mut T> { + pub fn poll_receive(&mut self, cx: &mut Context) -> Poll<&mut T> { self.channel.state.lock(|s| { let s = &mut *s.borrow_mut(); match s.pop_index() { @@ -122,7 +122,7 @@ impl<'a, M: RawMutex, T> Receiver<'a, M, T> { }) } - pub async fn recv(&mut self) -> &mut T { + pub async fn receive(&mut self) -> &mut T { let i = poll_fn(|cx| { self.channel.state.lock(|s| { let s = &mut *s.borrow_mut(); @@ -139,7 +139,7 @@ impl<'a, M: RawMutex, T> Receiver<'a, M, T> { unsafe { &mut *self.channel.buf.add(i) } } - pub fn recv_done(&mut self) { + pub fn receive_done(&mut self) { self.channel.state.lock(|s| s.borrow_mut().pop_done()) } } @@ -157,7 +157,7 @@ struct State { full: bool, send_waker: WakerRegistration, - recv_waker: WakerRegistration, + receive_waker: WakerRegistration, } impl State { @@ -204,6 +204,6 @@ impl State { assert!(!self.is_empty()); self.front = self.increment(self.front); self.full = false; - self.recv_waker.wake(); + self.receive_waker.wake(); } }