|
22 | 22 | //! The requirement for Drop is only strictly true if the IRQ handler calls `try_recv` and drops
|
23 | 23 | //! received message. If the message is *always* sent over another channel or otherwise not
|
24 | 24 | //! dropped, it *might* be safe to use these messages.
|
| 25 | +//! |
| 26 | +//! ## Dropping of Sender/Receiver |
| 27 | +//! |
| 28 | +//! Crossbeam channels support detecting when all senders or all receivers have been dropped on a |
| 29 | +//! channel, which will cause the handles on the other end to error, including waking up current |
| 30 | +//! threads waiting on those channels. |
| 31 | +//! |
| 32 | +//! At this time, this isn't implementable in Zephyr, as there is no API to wake up all threads |
| 33 | +//! blocked on a given `k_queue`. As such, this scenario is not supported. What actually happens |
| 34 | +//! is that when all senders or receivers on a channel are dropped, operations on the other end of |
| 35 | +//! the channel may just block (or queue forever with unbounded queues). If all handles (both |
| 36 | +//! sender and receiver) are dropped, the last drop will cause a panic. It maybe be better to just |
| 37 | +//! leak the entire channel, as any data associated with the channels would be leaked at this point, |
| 38 | +//! including the underlying Zephyr `k_queue`. Until APIs are added to Zephyr to allow the channel |
| 39 | +//! information to be safely freed, these can't actually be freed. |
25 | 40 |
|
26 | 41 | extern crate alloc;
|
27 | 42 |
|
@@ -187,15 +202,14 @@ impl<T> Drop for Sender<T> {
|
187 | 202 | SenderFlavor::Unbounded { queue, .. } => {
|
188 | 203 | unsafe {
|
189 | 204 | queue.release(|_| {
|
190 |
| - crate::printkln!("Release"); |
191 |
| - true |
| 205 | + panic!("Unbounded queues cannot currently be dropped"); |
192 | 206 | })
|
193 | 207 | }
|
194 | 208 | }
|
195 | 209 | SenderFlavor::Bounded(chan) => {
|
196 | 210 | unsafe {
|
197 | 211 | chan.release(|_| {
|
198 |
| - panic!("Bounded queues cannot be dropped"); |
| 212 | + panic!("Bounded queues cannot currently be dropped"); |
199 | 213 | })
|
200 | 214 | }
|
201 | 215 | }
|
|
0 commit comments