diff options
Diffstat (limited to 'embassy-sync/src/mutex.rs')
| -rw-r--r-- | embassy-sync/src/mutex.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/embassy-sync/src/mutex.rs b/embassy-sync/src/mutex.rs index 08f66e374..f25f74336 100644 --- a/embassy-sync/src/mutex.rs +++ b/embassy-sync/src/mutex.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | //! | 2 | //! |
| 3 | //! This module provides a mutex that can be used to synchronize data between asynchronous tasks. | 3 | //! This module provides a mutex that can be used to synchronize data between asynchronous tasks. |
| 4 | use core::cell::{RefCell, UnsafeCell}; | 4 | use core::cell::{RefCell, UnsafeCell}; |
| 5 | use core::future::poll_fn; | 5 | use core::future::{poll_fn, Future}; |
| 6 | use core::ops::{Deref, DerefMut}; | 6 | use core::ops::{Deref, DerefMut}; |
| 7 | use core::task::Poll; | 7 | use core::task::Poll; |
| 8 | use core::{fmt, mem}; | 8 | use core::{fmt, mem}; |
| @@ -73,7 +73,7 @@ where | |||
| 73 | /// Lock the mutex. | 73 | /// Lock the mutex. |
| 74 | /// | 74 | /// |
| 75 | /// This will wait for the mutex to be unlocked if it's already locked. | 75 | /// This will wait for the mutex to be unlocked if it's already locked. |
| 76 | pub async fn lock(&self) -> MutexGuard<'_, M, T> { | 76 | pub fn lock(&self) -> impl Future<Output = MutexGuard<'_, M, T>> { |
| 77 | poll_fn(|cx| { | 77 | poll_fn(|cx| { |
| 78 | let ready = self.state.lock(|s| { | 78 | let ready = self.state.lock(|s| { |
| 79 | let mut s = s.borrow_mut(); | 79 | let mut s = s.borrow_mut(); |
| @@ -92,7 +92,6 @@ where | |||
| 92 | Poll::Pending | 92 | Poll::Pending |
| 93 | } | 93 | } |
| 94 | }) | 94 | }) |
| 95 | .await | ||
| 96 | } | 95 | } |
| 97 | 96 | ||
| 98 | /// Attempt to immediately lock the mutex. | 97 | /// Attempt to immediately lock the mutex. |
