aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy/src/channel/pubsub/mod.rs8
-rw-r--r--embassy/src/executor/raw/mod.rs4
-rw-r--r--embassy/src/executor/spawner.rs4
-rw-r--r--embassy/src/util/forever.rs10
4 files changed, 19 insertions, 7 deletions
diff --git a/embassy/src/channel/pubsub/mod.rs b/embassy/src/channel/pubsub/mod.rs
index 11c889368..64a72a52c 100644
--- a/embassy/src/channel/pubsub/mod.rs
+++ b/embassy/src/channel/pubsub/mod.rs
@@ -104,7 +104,7 @@ impl<M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usi
104 /// Create a new subscriber. It will only receive messages that are published after its creation. 104 /// Create a new subscriber. It will only receive messages that are published after its creation.
105 /// 105 ///
106 /// If there are no subscriber slots left, an error will be returned. 106 /// If there are no subscriber slots left, an error will be returned.
107 pub fn dyn_subscriber<'a>(&'a self) -> Result<DynSubscriber<'a, T>, Error> { 107 pub fn dyn_subscriber(&self) -> Result<DynSubscriber<'_, T>, Error> {
108 self.inner.lock(|inner| { 108 self.inner.lock(|inner| {
109 let mut s = inner.borrow_mut(); 109 let mut s = inner.borrow_mut();
110 110
@@ -136,7 +136,7 @@ impl<M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usi
136 /// Create a new publisher 136 /// Create a new publisher
137 /// 137 ///
138 /// If there are no publisher slots left, an error will be returned. 138 /// If there are no publisher slots left, an error will be returned.
139 pub fn dyn_publisher<'a>(&'a self) -> Result<DynPublisher<'a, T>, Error> { 139 pub fn dyn_publisher(&self) -> Result<DynPublisher<'_, T>, Error> {
140 self.inner.lock(|inner| { 140 self.inner.lock(|inner| {
141 let mut s = inner.borrow_mut(); 141 let mut s = inner.borrow_mut();
142 142
@@ -369,7 +369,7 @@ impl<T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize> PubSubSta
369} 369}
370 370
371/// Error type for the [PubSubChannel] 371/// Error type for the [PubSubChannel]
372#[derive(Debug, PartialEq, Clone)] 372#[derive(Debug, PartialEq, Eq, Clone)]
373#[cfg_attr(feature = "defmt", derive(defmt::Format))] 373#[cfg_attr(feature = "defmt", derive(defmt::Format))]
374pub enum Error { 374pub enum Error {
375 /// All subscriber slots are used. To add another subscriber, first another subscriber must be dropped or 375 /// All subscriber slots are used. To add another subscriber, first another subscriber must be dropped or
@@ -404,7 +404,7 @@ pub trait PubSubBehavior<T> {
404} 404}
405 405
406/// The result of the subscriber wait procedure 406/// The result of the subscriber wait procedure
407#[derive(Debug, Clone, PartialEq)] 407#[derive(Debug, Clone, PartialEq, Eq)]
408#[cfg_attr(feature = "defmt", derive(defmt::Format))] 408#[cfg_attr(feature = "defmt", derive(defmt::Format))]
409pub enum WaitResult<T> { 409pub enum WaitResult<T> {
410 /// The subscriber did not receive all messages and lagged by the given amount of messages. 410 /// The subscriber did not receive all messages and lagged by the given amount of messages.
diff --git a/embassy/src/executor/raw/mod.rs b/embassy/src/executor/raw/mod.rs
index b8455442e..7e8559168 100644
--- a/embassy/src/executor/raw/mod.rs
+++ b/embassy/src/executor/raw/mod.rs
@@ -445,6 +445,10 @@ impl Executor {
445/// Wake a task by raw pointer. 445/// Wake a task by raw pointer.
446/// 446///
447/// You can obtain task pointers from `Waker`s using [`task_from_waker`]. 447/// You can obtain task pointers from `Waker`s using [`task_from_waker`].
448///
449/// # Safety
450///
451/// `task` must be a valid task pointer obtained from [`task_from_waker`].
448pub unsafe fn wake_task(task: NonNull<TaskHeader>) { 452pub unsafe fn wake_task(task: NonNull<TaskHeader>) {
449 task.as_ref().enqueue(); 453 task.as_ref().enqueue();
450} 454}
diff --git a/embassy/src/executor/spawner.rs b/embassy/src/executor/spawner.rs
index 884db6b55..c8d036eb8 100644
--- a/embassy/src/executor/spawner.rs
+++ b/embassy/src/executor/spawner.rs
@@ -93,7 +93,7 @@ impl Spawner {
93 pub async fn for_current_executor() -> Self { 93 pub async fn for_current_executor() -> Self {
94 poll_fn(|cx| unsafe { 94 poll_fn(|cx| unsafe {
95 let task = raw::task_from_waker(cx.waker()); 95 let task = raw::task_from_waker(cx.waker());
96 let executor = (&*task.as_ptr()).executor.get(); 96 let executor = (*task.as_ptr()).executor.get();
97 Poll::Ready(Self::new(&*executor)) 97 Poll::Ready(Self::new(&*executor))
98 }) 98 })
99 .await 99 .await
@@ -169,7 +169,7 @@ impl SendSpawner {
169 pub async fn for_current_executor() -> Self { 169 pub async fn for_current_executor() -> Self {
170 poll_fn(|cx| unsafe { 170 poll_fn(|cx| unsafe {
171 let task = raw::task_from_waker(cx.waker()); 171 let task = raw::task_from_waker(cx.waker());
172 let executor = (&*task.as_ptr()).executor.get(); 172 let executor = (*task.as_ptr()).executor.get();
173 Poll::Ready(Self::new(&*executor)) 173 Poll::Ready(Self::new(&*executor))
174 }) 174 })
175 .await 175 .await
diff --git a/embassy/src/util/forever.rs b/embassy/src/util/forever.rs
index e367d2643..0e0fee596 100644
--- a/embassy/src/util/forever.rs
+++ b/embassy/src/util/forever.rs
@@ -82,9 +82,17 @@ impl<T> Forever<T> {
82 } 82 }
83 } 83 }
84 84
85 /// Unsafely get a mutable reference to the contents of this Forever.
86 ///
87 /// # Safety
88 ///
89 /// This is undefined behavior if:
90 ///
91 /// - The `Forever` has not been initialized yet (with `put' or `put_with`), or
92 /// - A reference to the contents (mutable or not) already exists.
85 #[inline(always)] 93 #[inline(always)]
86 #[allow(clippy::mut_from_ref)] 94 #[allow(clippy::mut_from_ref)]
87 pub unsafe fn steal(&'static self) -> &'static mut T { 95 pub unsafe fn steal(&self) -> &mut T {
88 let p = self.t.get(); 96 let p = self.t.get();
89 let p = (&mut *p).as_mut_ptr(); 97 let p = (&mut *p).as_mut_ptr();
90 &mut *p 98 &mut *p