diff options
| author | Dion Dokter <[email protected]> | 2022-12-09 11:04:55 +0100 |
|---|---|---|
| committer | Dion Dokter <[email protected]> | 2022-12-09 11:04:55 +0100 |
| commit | f22297e3d62975a810f4bc7588ede421f14ebd93 (patch) | |
| tree | 4690d5c574013afae63bc8eabc290f547cc046a8 /embassy-sync/src | |
| parent | 1d2f97b4e226871014c2cf470070343df15d74a0 (diff) | |
| parent | 58ab82904970f2df3984e54c722955a7b7c81391 (diff) | |
Merge branch 'master' into nrf91/53-nvmc
Diffstat (limited to 'embassy-sync/src')
| -rw-r--r-- | embassy-sync/src/lib.rs | 3 | ||||
| -rw-r--r-- | embassy-sync/src/pipe.rs | 74 | ||||
| -rw-r--r-- | embassy-sync/src/signal.rs | 9 | ||||
| -rw-r--r-- | embassy-sync/src/waitqueue/waker.rs | 2 |
4 files changed, 30 insertions, 58 deletions
diff --git a/embassy-sync/src/lib.rs b/embassy-sync/src/lib.rs index 80bb907a3..f9435ecff 100644 --- a/embassy-sync/src/lib.rs +++ b/embassy-sync/src/lib.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] | 1 | #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] |
| 2 | #![cfg_attr(feature = "nightly", feature(type_alias_impl_trait))] | 2 | #![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections))] |
| 3 | #![cfg_attr(feature = "nightly", allow(incomplete_features))] | ||
| 3 | #![allow(clippy::new_without_default)] | 4 | #![allow(clippy::new_without_default)] |
| 4 | #![doc = include_str!("../README.md")] | 5 | #![doc = include_str!("../README.md")] |
| 5 | #![warn(missing_docs)] | 6 | #![warn(missing_docs)] |
diff --git a/embassy-sync/src/pipe.rs b/embassy-sync/src/pipe.rs index cd577f34f..905686acd 100644 --- a/embassy-sync/src/pipe.rs +++ b/embassy-sync/src/pipe.rs | |||
| @@ -352,8 +352,6 @@ where | |||
| 352 | mod io_impls { | 352 | mod io_impls { |
| 353 | use core::convert::Infallible; | 353 | use core::convert::Infallible; |
| 354 | 354 | ||
| 355 | use futures_util::FutureExt; | ||
| 356 | |||
| 357 | use super::*; | 355 | use super::*; |
| 358 | 356 | ||
| 359 | impl<M: RawMutex, const N: usize> embedded_io::Io for Pipe<M, N> { | 357 | impl<M: RawMutex, const N: usize> embedded_io::Io for Pipe<M, N> { |
| @@ -361,30 +359,18 @@ mod io_impls { | |||
| 361 | } | 359 | } |
| 362 | 360 | ||
| 363 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for Pipe<M, N> { | 361 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for Pipe<M, N> { |
| 364 | type ReadFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a | 362 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { |
| 365 | where | 363 | Ok(Pipe::read(self, buf).await) |
| 366 | Self: 'a; | ||
| 367 | |||
| 368 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 369 | Pipe::read(self, buf).map(Ok) | ||
| 370 | } | 364 | } |
| 371 | } | 365 | } |
| 372 | 366 | ||
| 373 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for Pipe<M, N> { | 367 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for Pipe<M, N> { |
| 374 | type WriteFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a | 368 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { |
| 375 | where | 369 | Ok(Pipe::write(self, buf).await) |
| 376 | Self: 'a; | ||
| 377 | |||
| 378 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 379 | Pipe::write(self, buf).map(Ok) | ||
| 380 | } | 370 | } |
| 381 | 371 | ||
| 382 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a | 372 | async fn flush(&mut self) -> Result<(), Self::Error> { |
| 383 | where | 373 | Ok(()) |
| 384 | Self: 'a; | ||
| 385 | |||
| 386 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | ||
| 387 | futures_util::future::ready(Ok(())) | ||
| 388 | } | 374 | } |
| 389 | } | 375 | } |
| 390 | 376 | ||
| @@ -393,30 +379,18 @@ mod io_impls { | |||
| 393 | } | 379 | } |
| 394 | 380 | ||
| 395 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for &Pipe<M, N> { | 381 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for &Pipe<M, N> { |
| 396 | type ReadFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a | 382 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { |
| 397 | where | 383 | Ok(Pipe::read(self, buf).await) |
| 398 | Self: 'a; | ||
| 399 | |||
| 400 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 401 | Pipe::read(self, buf).map(Ok) | ||
| 402 | } | 384 | } |
| 403 | } | 385 | } |
| 404 | 386 | ||
| 405 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for &Pipe<M, N> { | 387 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for &Pipe<M, N> { |
| 406 | type WriteFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a | 388 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { |
| 407 | where | 389 | Ok(Pipe::write(self, buf).await) |
| 408 | Self: 'a; | ||
| 409 | |||
| 410 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 411 | Pipe::write(self, buf).map(Ok) | ||
| 412 | } | 390 | } |
| 413 | 391 | ||
| 414 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a | 392 | async fn flush(&mut self) -> Result<(), Self::Error> { |
| 415 | where | 393 | Ok(()) |
| 416 | Self: 'a; | ||
| 417 | |||
| 418 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | ||
| 419 | futures_util::future::ready(Ok(())) | ||
| 420 | } | 394 | } |
| 421 | } | 395 | } |
| 422 | 396 | ||
| @@ -425,12 +399,8 @@ mod io_impls { | |||
| 425 | } | 399 | } |
| 426 | 400 | ||
| 427 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for Reader<'_, M, N> { | 401 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for Reader<'_, M, N> { |
| 428 | type ReadFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a | 402 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { |
| 429 | where | 403 | Ok(Reader::read(self, buf).await) |
| 430 | Self: 'a; | ||
| 431 | |||
| 432 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 433 | Reader::read(self, buf).map(Ok) | ||
| 434 | } | 404 | } |
| 435 | } | 405 | } |
| 436 | 406 | ||
| @@ -439,20 +409,12 @@ mod io_impls { | |||
| 439 | } | 409 | } |
| 440 | 410 | ||
| 441 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for Writer<'_, M, N> { | 411 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for Writer<'_, M, N> { |
| 442 | type WriteFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a | 412 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { |
| 443 | where | 413 | Ok(Writer::write(self, buf).await) |
| 444 | Self: 'a; | ||
| 445 | |||
| 446 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 447 | Writer::write(self, buf).map(Ok) | ||
| 448 | } | 414 | } |
| 449 | 415 | ||
| 450 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a | 416 | async fn flush(&mut self) -> Result<(), Self::Error> { |
| 451 | where | 417 | Ok(()) |
| 452 | Self: 'a; | ||
| 453 | |||
| 454 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | ||
| 455 | futures_util::future::ready(Ok(())) | ||
| 456 | } | 418 | } |
| 457 | } | 419 | } |
| 458 | } | 420 | } |
diff --git a/embassy-sync/src/signal.rs b/embassy-sync/src/signal.rs index c3c10a8af..bea67d8be 100644 --- a/embassy-sync/src/signal.rs +++ b/embassy-sync/src/signal.rs | |||
| @@ -56,6 +56,15 @@ where | |||
| 56 | } | 56 | } |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | impl<M, T> Default for Signal<M, T> | ||
| 60 | where | ||
| 61 | M: RawMutex, | ||
| 62 | { | ||
| 63 | fn default() -> Self { | ||
| 64 | Self::new() | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 59 | impl<M, T: Send> Signal<M, T> | 68 | impl<M, T: Send> Signal<M, T> |
| 60 | where | 69 | where |
| 61 | M: RawMutex, | 70 | M: RawMutex, |
diff --git a/embassy-sync/src/waitqueue/waker.rs b/embassy-sync/src/waitqueue/waker.rs index 64e300eb8..9ce94a089 100644 --- a/embassy-sync/src/waitqueue/waker.rs +++ b/embassy-sync/src/waitqueue/waker.rs | |||
| @@ -6,7 +6,7 @@ use crate::blocking_mutex::raw::CriticalSectionRawMutex; | |||
| 6 | use crate::blocking_mutex::Mutex; | 6 | use crate::blocking_mutex::Mutex; |
| 7 | 7 | ||
| 8 | /// Utility struct to register and wake a waker. | 8 | /// Utility struct to register and wake a waker. |
| 9 | #[derive(Debug)] | 9 | #[derive(Debug, Default)] |
| 10 | pub struct WakerRegistration { | 10 | pub struct WakerRegistration { |
| 11 | waker: Option<Waker>, | 11 | waker: Option<Waker>, |
| 12 | } | 12 | } |
