diff options
| author | Ulf Lilleengen <[email protected]> | 2021-08-02 11:18:59 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2021-08-02 11:18:59 +0200 |
| commit | 4d8d8e386f9e85a6273cf93f1c8feb5871ed96af (patch) | |
| tree | 8bdc4ab39e8ca9a5114fc5c5acf8eda01337e137 | |
| parent | 332bc44b8c3687492b85ff3ad3f4ea7b67608dd2 (diff) | |
Make RecvFuture sync
RecvFuture always locks the underlying Channel when polled.
| -rw-r--r-- | embassy/src/util/mpsc.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/embassy/src/util/mpsc.rs b/embassy/src/util/mpsc.rs index d41c86291..4c6e8a6f0 100644 --- a/embassy/src/util/mpsc.rs +++ b/embassy/src/util/mpsc.rs | |||
| @@ -218,6 +218,16 @@ where | |||
| 218 | } | 218 | } |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | // Safe to pass the receive future around since it locks channel whenever polled | ||
| 222 | unsafe impl<'ch, M, T, const N: usize> Send for RecvFuture<'ch, M, T, N> where | ||
| 223 | M: Mutex<Data = ()> + Sync | ||
| 224 | { | ||
| 225 | } | ||
| 226 | unsafe impl<'ch, M, T, const N: usize> Sync for RecvFuture<'ch, M, T, N> where | ||
| 227 | M: Mutex<Data = ()> + Sync | ||
| 228 | { | ||
| 229 | } | ||
| 230 | |||
| 221 | impl<'ch, M, T, const N: usize> Sender<'ch, M, T, N> | 231 | impl<'ch, M, T, const N: usize> Sender<'ch, M, T, N> |
| 222 | where | 232 | where |
| 223 | M: Mutex<Data = ()>, | 233 | M: Mutex<Data = ()>, |
