aboutsummaryrefslogtreecommitdiff
path: root/embassy-sync/src/channel.rs
diff options
context:
space:
mode:
authorScott Mabin <[email protected]>2023-11-18 15:01:12 +0000
committerScott Mabin <[email protected]>2023-11-18 15:01:12 +0000
commitf482a105b8491f3c21d41cb7e6f52fe6d778258f (patch)
treeafd4e5a46641f7111186eb578b2c56b3f1645ff7 /embassy-sync/src/channel.rs
parent7589b5e13e0e01922804e603918fea0aa4dac30a (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.rs8
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;
29use crate::blocking_mutex::Mutex; 29use crate::blocking_mutex::Mutex;
30use crate::waitqueue::WakerRegistration; 30use crate::waitqueue::WakerRegistration;
31 31
32pub mod priority;
33
32/// Send-only access to a [`Channel`]. 34/// Send-only access to a [`Channel`].
33pub struct Sender<'ch, M, T, const N: usize> 35pub struct Sender<'ch, M, T, const N: usize>
34where 36where
@@ -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.
78pub struct DynamicSender<'ch, T> { 80pub struct DynamicSender<'ch, T> {
79 pub(crate) channel: &'ch dyn DynamicChannel<T>, 81 channel: &'ch dyn DynamicChannel<T>,
80} 82}
81 83
82impl<'ch, T> Clone for DynamicSender<'ch, T> { 84impl<'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.
178pub struct DynamicReceiver<'ch, T> { 180pub struct DynamicReceiver<'ch, T> {
179 pub(crate) channel: &'ch dyn DynamicChannel<T>, 181 channel: &'ch dyn DynamicChannel<T>,
180} 182}
181 183
182impl<'ch, T> Clone for DynamicReceiver<'ch, T> { 184impl<'ch, T> Clone for DynamicReceiver<'ch, T> {
@@ -321,7 +323,7 @@ impl<'ch, T> Future for DynamicSendFuture<'ch, T> {
321 323
322impl<'ch, T> Unpin for DynamicSendFuture<'ch, T> {} 324impl<'ch, T> Unpin for DynamicSendFuture<'ch, T> {}
323 325
324pub(crate) trait DynamicChannel<T> { 326trait 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>;