aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben De Smet <[email protected]>2023-08-11 12:07:30 +0200
committerDario Nieuwenhuis <[email protected]>2023-09-04 22:13:27 +0200
commit1eb03dc41a4a5fa8435f9a49d26e29ceea6d498e (patch)
tree21c150dfc1720c085a2bb665aec30f3453f58816
parenta2656f402b1c59461cec5f5dc685b2692119b996 (diff)
Prefer `receive` over `recv`
-rw-r--r--embassy-net-driver-channel/src/lib.rs22
-rw-r--r--embassy-sync/src/zero_copy_channel.rs18
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 e8cd66f8d..a20760749 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> {
131 } 131 }
132 132
133 pub async fn tx_buf(&mut self) -> &mut [u8] { 133 pub async fn tx_buf(&mut self) -> &mut [u8] {
134 let p = self.tx_chan.recv().await; 134 let p = self.tx_chan.receive().await;
135 &mut p.buf[..p.len] 135 &mut p.buf[..p.len]
136 } 136 }
137 137
138 pub fn try_tx_buf(&mut self) -> Option<&mut [u8]> { 138 pub fn try_tx_buf(&mut self) -> Option<&mut [u8]> {
139 let p = self.tx_chan.try_recv()?; 139 let p = self.tx_chan.try_receive()?;
140 Some(&mut p.buf[..p.len]) 140 Some(&mut p.buf[..p.len])
141 } 141 }
142 142
143 pub fn poll_tx_buf(&mut self, cx: &mut Context) -> Poll<&mut [u8]> { 143 pub fn poll_tx_buf(&mut self, cx: &mut Context) -> Poll<&mut [u8]> {
144 match self.tx_chan.poll_recv(cx) { 144 match self.tx_chan.poll_receive(cx) {
145 Poll::Ready(p) => Poll::Ready(&mut p.buf[..p.len]), 145 Poll::Ready(p) => Poll::Ready(&mut p.buf[..p.len]),
146 Poll::Pending => Poll::Pending, 146 Poll::Pending => Poll::Pending,
147 } 147 }
148 } 148 }
149 149
150 pub fn tx_done(&mut self) { 150 pub fn tx_done(&mut self) {
151 self.tx_chan.recv_done(); 151 self.tx_chan.receive_done();
152 } 152 }
153} 153}
154 154
@@ -205,24 +205,24 @@ impl<'d, const MTU: usize> RxRunner<'d, MTU> {
205 205
206impl<'d, const MTU: usize> TxRunner<'d, MTU> { 206impl<'d, const MTU: usize> TxRunner<'d, MTU> {
207 pub async fn tx_buf(&mut self) -> &mut [u8] { 207 pub async fn tx_buf(&mut self) -> &mut [u8] {
208 let p = self.tx_chan.recv().await; 208 let p = self.tx_chan.receive().await;
209 &mut p.buf[..p.len] 209 &mut p.buf[..p.len]
210 } 210 }
211 211
212 pub fn try_tx_buf(&mut self) -> Option<&mut [u8]> { 212 pub fn try_tx_buf(&mut self) -> Option<&mut [u8]> {
213 let p = self.tx_chan.try_recv()?; 213 let p = self.tx_chan.try_receive()?;
214 Some(&mut p.buf[..p.len]) 214 Some(&mut p.buf[..p.len])
215 } 215 }
216 216
217 pub fn poll_tx_buf(&mut self, cx: &mut Context) -> Poll<&mut [u8]> { 217 pub fn poll_tx_buf(&mut self, cx: &mut Context) -> Poll<&mut [u8]> {
218 match self.tx_chan.poll_recv(cx) { 218 match self.tx_chan.poll_receive(cx) {
219 Poll::Ready(p) => Poll::Ready(&mut p.buf[..p.len]), 219 Poll::Ready(p) => Poll::Ready(&mut p.buf[..p.len]),
220 Poll::Pending => Poll::Pending, 220 Poll::Pending => Poll::Pending,
221 } 221 }
222 } 222 }
223 223
224 pub fn tx_done(&mut self) { 224 pub fn tx_done(&mut self) {
225 self.tx_chan.recv_done(); 225 self.tx_chan.receive_done();
226 } 226 }
227} 227}
228 228
@@ -294,7 +294,7 @@ impl<'d, const MTU: usize> embassy_net_driver::Driver for Device<'d, MTU> {
294 type TxToken<'a> = TxToken<'a, MTU> where Self: 'a ; 294 type TxToken<'a> = TxToken<'a, MTU> where Self: 'a ;
295 295
296 fn receive(&mut self, cx: &mut Context) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)> { 296 fn receive(&mut self, cx: &mut Context) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)> {
297 if self.rx.poll_recv(cx).is_ready() && self.tx.poll_send(cx).is_ready() { 297 if self.rx.poll_receive(cx).is_ready() && self.tx.poll_send(cx).is_ready() {
298 Some((RxToken { rx: self.rx.borrow() }, TxToken { tx: self.tx.borrow() })) 298 Some((RxToken { rx: self.rx.borrow() }, TxToken { tx: self.tx.borrow() }))
299 } else { 299 } else {
300 None 300 None
@@ -338,9 +338,9 @@ impl<'a, const MTU: usize> embassy_net_driver::RxToken for RxToken<'a, MTU> {
338 F: FnOnce(&mut [u8]) -> R, 338 F: FnOnce(&mut [u8]) -> R,
339 { 339 {
340 // NOTE(unwrap): we checked the queue wasn't full when creating the token. 340 // NOTE(unwrap): we checked the queue wasn't full when creating the token.
341 let pkt = unwrap!(self.rx.try_recv()); 341 let pkt = unwrap!(self.rx.try_receive());
342 let r = f(&mut pkt.buf[..pkt.len]); 342 let r = f(&mut pkt.buf[..pkt.len]);
343 self.rx.recv_done(); 343 self.rx.receive_done();
344 r 344 r
345 } 345 }
346} 346}
diff --git a/embassy-sync/src/zero_copy_channel.rs b/embassy-sync/src/zero_copy_channel.rs
index 3701ccf1a..cbb8cb526 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> {
27 back: 0, 27 back: 0,
28 full: false, 28 full: false,
29 send_waker: WakerRegistration::new(), 29 send_waker: WakerRegistration::new(),
30 recv_waker: WakerRegistration::new(), 30 receive_waker: WakerRegistration::new(),
31 })), 31 })),
32 } 32 }
33 } 33 }
@@ -62,7 +62,7 @@ impl<'a, M: RawMutex, T> Sender<'a, M, T> {
62 match s.push_index() { 62 match s.push_index() {
63 Some(i) => Poll::Ready(unsafe { &mut *self.channel.buf.add(i) }), 63 Some(i) => Poll::Ready(unsafe { &mut *self.channel.buf.add(i) }),
64 None => { 64 None => {
65 s.recv_waker.register(cx.waker()); 65 s.receive_waker.register(cx.waker());
66 Poll::Pending 66 Poll::Pending
67 } 67 }
68 } 68 }
@@ -76,7 +76,7 @@ impl<'a, M: RawMutex, T> Sender<'a, M, T> {
76 match s.push_index() { 76 match s.push_index() {
77 Some(i) => Poll::Ready(i), 77 Some(i) => Poll::Ready(i),
78 None => { 78 None => {
79 s.recv_waker.register(cx.waker()); 79 s.receive_waker.register(cx.waker());
80 Poll::Pending 80 Poll::Pending
81 } 81 }
82 } 82 }
@@ -99,7 +99,7 @@ impl<'a, M: RawMutex, T> Receiver<'a, M, T> {
99 Receiver { channel: self.channel } 99 Receiver { channel: self.channel }
100 } 100 }
101 101
102 pub fn try_recv(&mut self) -> Option<&mut T> { 102 pub fn try_receive(&mut self) -> Option<&mut T> {
103 self.channel.state.lock(|s| { 103 self.channel.state.lock(|s| {
104 let s = &mut *s.borrow_mut(); 104 let s = &mut *s.borrow_mut();
105 match s.pop_index() { 105 match s.pop_index() {
@@ -109,7 +109,7 @@ impl<'a, M: RawMutex, T> Receiver<'a, M, T> {
109 }) 109 })
110 } 110 }
111 111
112 pub fn poll_recv(&mut self, cx: &mut Context) -> Poll<&mut T> { 112 pub fn poll_receive(&mut self, cx: &mut Context) -> Poll<&mut T> {
113 self.channel.state.lock(|s| { 113 self.channel.state.lock(|s| {
114 let s = &mut *s.borrow_mut(); 114 let s = &mut *s.borrow_mut();
115 match s.pop_index() { 115 match s.pop_index() {
@@ -122,7 +122,7 @@ impl<'a, M: RawMutex, T> Receiver<'a, M, T> {
122 }) 122 })
123 } 123 }
124 124
125 pub async fn recv(&mut self) -> &mut T { 125 pub async fn receive(&mut self) -> &mut T {
126 let i = poll_fn(|cx| { 126 let i = poll_fn(|cx| {
127 self.channel.state.lock(|s| { 127 self.channel.state.lock(|s| {
128 let s = &mut *s.borrow_mut(); 128 let s = &mut *s.borrow_mut();
@@ -139,7 +139,7 @@ impl<'a, M: RawMutex, T> Receiver<'a, M, T> {
139 unsafe { &mut *self.channel.buf.add(i) } 139 unsafe { &mut *self.channel.buf.add(i) }
140 } 140 }
141 141
142 pub fn recv_done(&mut self) { 142 pub fn receive_done(&mut self) {
143 self.channel.state.lock(|s| s.borrow_mut().pop_done()) 143 self.channel.state.lock(|s| s.borrow_mut().pop_done())
144 } 144 }
145} 145}
@@ -157,7 +157,7 @@ struct State {
157 full: bool, 157 full: bool,
158 158
159 send_waker: WakerRegistration, 159 send_waker: WakerRegistration,
160 recv_waker: WakerRegistration, 160 receive_waker: WakerRegistration,
161} 161}
162 162
163impl State { 163impl State {
@@ -204,6 +204,6 @@ impl State {
204 assert!(!self.is_empty()); 204 assert!(!self.is_empty());
205 self.front = self.increment(self.front); 205 self.front = self.increment(self.front);
206 self.full = false; 206 self.full = false;
207 self.recv_waker.wake(); 207 self.receive_waker.wake();
208 } 208 }
209} 209}