diff options
| author | Dániel Buga <[email protected]> | 2023-08-12 16:00:18 +0200 |
|---|---|---|
| committer | Dániel Buga <[email protected]> | 2023-08-12 18:29:56 +0200 |
| commit | 675b7fb6056d8c3dfaca759b7cd373e2f4a0e111 (patch) | |
| tree | ef4f786edd849f9ce82cffa3b1d58e939a4f53a7 /embassy-executor/src/raw/mod.rs | |
| parent | 0727f8690c4684d0622547edee2cf9dc22215a9b (diff) | |
POC: allow custom executors
Diffstat (limited to 'embassy-executor/src/raw/mod.rs')
| -rw-r--r-- | embassy-executor/src/raw/mod.rs | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index 25c2ab0da..b4d70b1e9 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs | |||
| @@ -291,12 +291,29 @@ impl<F: Future + 'static, const N: usize> TaskPool<F, N> { | |||
| 291 | } | 291 | } |
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | /// Context given to the thread-mode executor's pender. | ||
| 295 | #[cfg(all(feature = "executor-thread", not(feature = "thread-context")))] | ||
| 296 | #[derive(Clone, Copy)] | ||
| 297 | #[repr(transparent)] | ||
| 298 | pub struct OpaqueThreadContext(pub(crate) ()); | ||
| 299 | |||
| 300 | /// Context given to the thread-mode executor's pender. | ||
| 301 | #[cfg(all(feature = "executor-thread", feature = "thread-context"))] | ||
| 302 | #[repr(transparent)] | ||
| 303 | #[derive(Clone, Copy)] | ||
| 304 | pub struct OpaqueThreadContext(pub(crate) usize); | ||
| 305 | |||
| 306 | /// Context given to the interrupt-mode executor's pender. | ||
| 307 | #[derive(Clone, Copy)] | ||
| 308 | #[repr(transparent)] | ||
| 309 | pub struct OpaqueInterruptContext(pub(crate) usize); | ||
| 310 | |||
| 294 | #[derive(Clone, Copy)] | 311 | #[derive(Clone, Copy)] |
| 295 | pub(crate) enum PenderInner { | 312 | pub(crate) enum PenderInner { |
| 296 | #[cfg(feature = "executor-thread")] | 313 | #[cfg(feature = "executor-thread")] |
| 297 | Thread(crate::arch::ThreadPender), | 314 | Thread(OpaqueThreadContext), |
| 298 | #[cfg(feature = "executor-interrupt")] | 315 | #[cfg(feature = "executor-interrupt")] |
| 299 | Interrupt(crate::arch::InterruptPender), | 316 | Interrupt(OpaqueInterruptContext), |
| 300 | #[cfg(feature = "pender-callback")] | 317 | #[cfg(feature = "pender-callback")] |
| 301 | Callback { func: fn(*mut ()), context: *mut () }, | 318 | Callback { func: fn(*mut ()), context: *mut () }, |
| 302 | } | 319 | } |
| @@ -333,9 +350,19 @@ impl Pender { | |||
| 333 | pub(crate) fn pend(&self) { | 350 | pub(crate) fn pend(&self) { |
| 334 | match self.0 { | 351 | match self.0 { |
| 335 | #[cfg(feature = "executor-thread")] | 352 | #[cfg(feature = "executor-thread")] |
| 336 | PenderInner::Thread(x) => x.pend(), | 353 | PenderInner::Thread(core_id) => { |
| 354 | extern "Rust" { | ||
| 355 | fn __thread_mode_pender(core_id: OpaqueThreadContext); | ||
| 356 | } | ||
| 357 | unsafe { __thread_mode_pender(core_id) }; | ||
| 358 | } | ||
| 337 | #[cfg(feature = "executor-interrupt")] | 359 | #[cfg(feature = "executor-interrupt")] |
| 338 | PenderInner::Interrupt(x) => x.pend(), | 360 | PenderInner::Interrupt(interrupt) => { |
| 361 | extern "Rust" { | ||
| 362 | fn __interrupt_mode_pender(interrupt: OpaqueInterruptContext); | ||
| 363 | } | ||
| 364 | unsafe { __interrupt_mode_pender(interrupt) }; | ||
| 365 | } | ||
| 339 | #[cfg(feature = "pender-callback")] | 366 | #[cfg(feature = "pender-callback")] |
| 340 | PenderInner::Callback { func, context } => func(context), | 367 | PenderInner::Callback { func, context } => func(context), |
| 341 | } | 368 | } |
