diff options
| author | Scott Mabin <[email protected]> | 2023-11-18 15:01:12 +0000 |
|---|---|---|
| committer | Scott Mabin <[email protected]> | 2023-11-18 15:01:12 +0000 |
| commit | f482a105b8491f3c21d41cb7e6f52fe6d778258f (patch) | |
| tree | afd4e5a46641f7111186eb578b2c56b3f1645ff7 /embassy-sync/src/channel.rs | |
| parent | 7589b5e13e0e01922804e603918fea0aa4dac30a (diff) | |
more clean up, refactor channel into module to share code
Diffstat (limited to 'embassy-sync/src/channel.rs')
| -rw-r--r-- | embassy-sync/src/channel.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/embassy-sync/src/channel.rs b/embassy-sync/src/channel.rs index ff7129303..1843bbae0 100644 --- a/embassy-sync/src/channel.rs +++ b/embassy-sync/src/channel.rs | |||
| @@ -29,6 +29,8 @@ use crate::blocking_mutex::raw::RawMutex; | |||
| 29 | use crate::blocking_mutex::Mutex; | 29 | use crate::blocking_mutex::Mutex; |
| 30 | use crate::waitqueue::WakerRegistration; | 30 | use crate::waitqueue::WakerRegistration; |
| 31 | 31 | ||
| 32 | pub mod priority; | ||
| 33 | |||
| 32 | /// Send-only access to a [`Channel`]. | 34 | /// Send-only access to a [`Channel`]. |
| 33 | pub struct Sender<'ch, M, T, const N: usize> | 35 | pub struct Sender<'ch, M, T, const N: usize> |
| 34 | where | 36 | where |
| @@ -76,7 +78,7 @@ where | |||
| 76 | 78 | ||
| 77 | /// Send-only access to a [`Channel`] without knowing channel size. | 79 | /// Send-only access to a [`Channel`] without knowing channel size. |
| 78 | pub struct DynamicSender<'ch, T> { | 80 | pub struct DynamicSender<'ch, T> { |
| 79 | pub(crate) channel: &'ch dyn DynamicChannel<T>, | 81 | channel: &'ch dyn DynamicChannel<T>, |
| 80 | } | 82 | } |
| 81 | 83 | ||
| 82 | impl<'ch, T> Clone for DynamicSender<'ch, T> { | 84 | impl<'ch, T> Clone for DynamicSender<'ch, T> { |
| @@ -176,7 +178,7 @@ where | |||
| 176 | 178 | ||
| 177 | /// Receive-only access to a [`Channel`] without knowing channel size. | 179 | /// Receive-only access to a [`Channel`] without knowing channel size. |
| 178 | pub struct DynamicReceiver<'ch, T> { | 180 | pub struct DynamicReceiver<'ch, T> { |
| 179 | pub(crate) channel: &'ch dyn DynamicChannel<T>, | 181 | channel: &'ch dyn DynamicChannel<T>, |
| 180 | } | 182 | } |
| 181 | 183 | ||
| 182 | impl<'ch, T> Clone for DynamicReceiver<'ch, T> { | 184 | impl<'ch, T> Clone for DynamicReceiver<'ch, T> { |
| @@ -321,7 +323,7 @@ impl<'ch, T> Future for DynamicSendFuture<'ch, T> { | |||
| 321 | 323 | ||
| 322 | impl<'ch, T> Unpin for DynamicSendFuture<'ch, T> {} | 324 | impl<'ch, T> Unpin for DynamicSendFuture<'ch, T> {} |
| 323 | 325 | ||
| 324 | pub(crate) trait DynamicChannel<T> { | 326 | trait DynamicChannel<T> { |
| 325 | fn try_send_with_context(&self, message: T, cx: Option<&mut Context<'_>>) -> Result<(), TrySendError<T>>; | 327 | fn try_send_with_context(&self, message: T, cx: Option<&mut Context<'_>>) -> Result<(), TrySendError<T>>; |
| 326 | 328 | ||
| 327 | fn try_receive_with_context(&self, cx: Option<&mut Context<'_>>) -> Result<T, TryReceiveError>; | 329 | fn try_receive_with_context(&self, cx: Option<&mut Context<'_>>) -> Result<T, TryReceiveError>; |
