aboutsummaryrefslogtreecommitdiff
path: root/embassy-sync
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 /embassy-sync
parenta2656f402b1c59461cec5f5dc685b2692119b996 (diff)
Prefer `receive` over `recv`
Diffstat (limited to 'embassy-sync')
-rw-r--r--embassy-sync/src/zero_copy_channel.rs18
1 files changed, 9 insertions, 9 deletions
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}