diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-01-21 00:59:09 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-01-21 01:00:12 +0100 |
| commit | 5b897b6605e571adb148ff1a35ea7ab3973861b0 (patch) | |
| tree | 7b0f04b66226dc210f407f0b6c6d85bd0636bebe | |
| parent | 28b5d8e9f4796696464b4b47ec27f873f96a70e4 (diff) | |
executor: Add 'raw' api to wake tasks through raw pointers.
| -rw-r--r-- | embassy/src/executor/mod.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/embassy/src/executor/mod.rs b/embassy/src/executor/mod.rs index 5e8354767..922b0fe0c 100644 --- a/embassy/src/executor/mod.rs +++ b/embassy/src/executor/mod.rs | |||
| @@ -259,3 +259,18 @@ pub(crate) unsafe fn register_timer(at: Instant, waker: &Waker) { | |||
| 259 | let expires_at = header.expires_at.get(); | 259 | let expires_at = header.expires_at.get(); |
| 260 | header.expires_at.set(min(expires_at, at)); | 260 | header.expires_at.set(min(expires_at, at)); |
| 261 | } | 261 | } |
| 262 | |||
| 263 | pub mod raw { | ||
| 264 | use super::waker; | ||
| 265 | use core::ptr::NonNull; | ||
| 266 | use core::task::Waker; | ||
| 267 | |||
| 268 | pub fn task_from_waker(waker: &Waker) -> NonNull<()> { | ||
| 269 | unsafe { NonNull::new_unchecked(waker::task_from_waker(waker) as *mut ()) } | ||
| 270 | } | ||
| 271 | |||
| 272 | pub unsafe fn wake_task(task: NonNull<()>) { | ||
| 273 | let header = &*waker::task_from_ptr(task.as_ptr()); | ||
| 274 | header.enqueue(); | ||
| 275 | } | ||
| 276 | } | ||
