diff options
| -rw-r--r-- | embassy/src/channel/pubsub.rs | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/embassy/src/channel/pubsub.rs b/embassy/src/channel/pubsub.rs index c5a8c01f8..cc00f47af 100644 --- a/embassy/src/channel/pubsub.rs +++ b/embassy/src/channel/pubsub.rs | |||
| @@ -356,12 +356,11 @@ impl<'a, T: Clone> Drop for Subscriber<'a, T> { | |||
| 356 | impl<'a, T: Clone> futures::Stream for Subscriber<'a, T> { | 356 | impl<'a, T: Clone> futures::Stream for Subscriber<'a, T> { |
| 357 | type Item = T; | 357 | type Item = T; |
| 358 | 358 | ||
| 359 | fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { | 359 | fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { |
| 360 | let this = unsafe { self.get_unchecked_mut() }; | 360 | let sub_index = self.subscriber_index; |
| 361 | 361 | match self | |
| 362 | match this | ||
| 363 | .channel | 362 | .channel |
| 364 | .get_message_with_context(&mut this.next_message_id, this.subscriber_index, Some(cx)) | 363 | .get_message_with_context(&mut self.next_message_id, sub_index, Some(cx)) |
| 365 | { | 364 | { |
| 366 | Poll::Ready(WaitResult::Message(message)) => Poll::Ready(Some(message)), | 365 | Poll::Ready(WaitResult::Message(message)) => Poll::Ready(Some(message)), |
| 367 | Poll::Ready(WaitResult::Lagged(_)) => { | 366 | Poll::Ready(WaitResult::Lagged(_)) => { |
| @@ -487,18 +486,16 @@ pub struct PublisherWaitFuture<'s, 'a, T: Clone> { | |||
| 487 | impl<'s, 'a, T: Clone> Future for PublisherWaitFuture<'s, 'a, T> { | 486 | impl<'s, 'a, T: Clone> Future for PublisherWaitFuture<'s, 'a, T> { |
| 488 | type Output = (); | 487 | type Output = (); |
| 489 | 488 | ||
| 490 | fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | 489 | fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { |
| 491 | let this = unsafe { self.get_unchecked_mut() }; | 490 | let message = self.message.take().unwrap(); |
| 492 | 491 | match self | |
| 493 | let message = this.message.take().unwrap(); | ||
| 494 | match this | ||
| 495 | .publisher | 492 | .publisher |
| 496 | .channel | 493 | .channel |
| 497 | .publish_with_context(message, this.publisher.publisher_index, Some(cx)) | 494 | .publish_with_context(message, self.publisher.publisher_index, Some(cx)) |
| 498 | { | 495 | { |
| 499 | Ok(()) => Poll::Ready(()), | 496 | Ok(()) => Poll::Ready(()), |
| 500 | Err(message) => { | 497 | Err(message) => { |
| 501 | this.message = Some(message); | 498 | self.message = Some(message); |
| 502 | Poll::Pending | 499 | Poll::Pending |
| 503 | } | 500 | } |
| 504 | } | 501 | } |
