diff options
| author | huntc <[email protected]> | 2021-12-10 12:08:00 +1100 |
|---|---|---|
| committer | huntc <[email protected]> | 2021-12-10 12:16:08 +1100 |
| commit | 7256ff3e71ceea9091349b040a2ebc987aca590c (patch) | |
| tree | 6f23c25b08c027db1dd133a7489b50661e08da7c /embassy-nrf/src | |
| parent | 60b7c50d8b02f92844287b150c5f504750846625 (diff) | |
Provides AsyncWrite with flush
As per Tokio and others, this commit provides a `poll_flush` method on `AsyncWrite` so that a best-effort attempt at wakening once all bytes are flushed can be made.
Diffstat (limited to 'embassy-nrf/src')
| -rw-r--r-- | embassy-nrf/src/buffered_uarte.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs index 9b0451c12..e3ca74384 100644 --- a/embassy-nrf/src/buffered_uarte.rs +++ b/embassy-nrf/src/buffered_uarte.rs | |||
| @@ -266,6 +266,20 @@ impl<'d, U: UarteInstance, T: TimerInstance> AsyncWrite for BufferedUarte<'d, U, | |||
| 266 | 266 | ||
| 267 | poll | 267 | poll |
| 268 | } | 268 | } |
| 269 | |||
| 270 | fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<embassy::io::Result<()>> { | ||
| 271 | self.inner.with(|state| { | ||
| 272 | trace!("poll_flush"); | ||
| 273 | |||
| 274 | if !state.tx.is_empty() { | ||
| 275 | trace!("poll_flush: pending"); | ||
| 276 | state.tx_waker.register(cx.waker()); | ||
| 277 | return Poll::Pending; | ||
| 278 | } | ||
| 279 | |||
| 280 | Poll::Ready(Ok(())) | ||
| 281 | }) | ||
| 282 | } | ||
| 269 | } | 283 | } |
| 270 | 284 | ||
| 271 | impl<'a, U: UarteInstance, T: TimerInstance> Drop for StateInner<'a, U, T> { | 285 | impl<'a, U: UarteInstance, T: TimerInstance> Drop for StateInner<'a, U, T> { |
