aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/raw/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-executor/src/raw/mod.rs')
-rw-r--r--embassy-executor/src/raw/mod.rs42
1 files changed, 21 insertions, 21 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs
index b4d70b1e9..7fd29db40 100644
--- a/embassy-executor/src/raw/mod.rs
+++ b/embassy-executor/src/raw/mod.rs
@@ -308,27 +308,30 @@ pub struct OpaqueThreadContext(pub(crate) usize);
308#[repr(transparent)] 308#[repr(transparent)]
309pub struct OpaqueInterruptContext(pub(crate) usize); 309pub struct OpaqueInterruptContext(pub(crate) usize);
310 310
311/// Platform/architecture-specific action executed when an executor has pending work.
312///
313/// When a task within an executor is woken, the `Pender` is called. This does a
314/// platform/architecture-specific action to signal there is pending work in the executor.
315/// When this happens, you must arrange for [`Executor::poll`] to be called.
316///
317/// You can think of it as a waker, but for the whole executor.
311#[derive(Clone, Copy)] 318#[derive(Clone, Copy)]
312pub(crate) enum PenderInner { 319pub enum Pender {
320 /// Pender for a thread-mode executor.
313 #[cfg(feature = "executor-thread")] 321 #[cfg(feature = "executor-thread")]
314 Thread(OpaqueThreadContext), 322 Thread(OpaqueThreadContext),
323
324 /// Pender for an interrupt-mode executor.
315 #[cfg(feature = "executor-interrupt")] 325 #[cfg(feature = "executor-interrupt")]
316 Interrupt(OpaqueInterruptContext), 326 Interrupt(OpaqueInterruptContext),
327
328 /// Arbitrary, dynamically dispatched pender.
317 #[cfg(feature = "pender-callback")] 329 #[cfg(feature = "pender-callback")]
318 Callback { func: fn(*mut ()), context: *mut () }, 330 Callback { func: fn(*mut ()), context: *mut () },
319} 331}
320 332
321unsafe impl Send for PenderInner {} 333unsafe impl Send for Pender {}
322unsafe impl Sync for PenderInner {} 334unsafe impl Sync for Pender {}
323
324/// Platform/architecture-specific action executed when an executor has pending work.
325///
326/// When a task within an executor is woken, the `Pender` is called. This does a
327/// platform/architecture-specific action to signal there is pending work in the executor.
328/// When this happens, you must arrange for [`Executor::poll`] to be called.
329///
330/// You can think of it as a waker, but for the whole executor.
331pub struct Pender(pub(crate) PenderInner);
332 335
333impl Pender { 336impl Pender {
334 /// Create a `Pender` that will call an arbitrary function pointer. 337 /// Create a `Pender` that will call an arbitrary function pointer.
@@ -339,32 +342,29 @@ impl Pender {
339 /// - `context`: Opaque context pointer, that will be passed to the function pointer. 342 /// - `context`: Opaque context pointer, that will be passed to the function pointer.
340 #[cfg(feature = "pender-callback")] 343 #[cfg(feature = "pender-callback")]
341 pub fn new_from_callback(func: fn(*mut ()), context: *mut ()) -> Self { 344 pub fn new_from_callback(func: fn(*mut ()), context: *mut ()) -> Self {
342 Self(PenderInner::Callback { 345 Self::Callback { func, context }
343 func,
344 context: context.into(),
345 })
346 } 346 }
347} 347}
348 348
349impl Pender { 349impl Pender {
350 pub(crate) fn pend(&self) { 350 pub(crate) fn pend(self) {
351 match self.0 { 351 match self {
352 #[cfg(feature = "executor-thread")] 352 #[cfg(feature = "executor-thread")]
353 PenderInner::Thread(core_id) => { 353 Pender::Thread(core_id) => {
354 extern "Rust" { 354 extern "Rust" {
355 fn __thread_mode_pender(core_id: OpaqueThreadContext); 355 fn __thread_mode_pender(core_id: OpaqueThreadContext);
356 } 356 }
357 unsafe { __thread_mode_pender(core_id) }; 357 unsafe { __thread_mode_pender(core_id) };
358 } 358 }
359 #[cfg(feature = "executor-interrupt")] 359 #[cfg(feature = "executor-interrupt")]
360 PenderInner::Interrupt(interrupt) => { 360 Pender::Interrupt(interrupt) => {
361 extern "Rust" { 361 extern "Rust" {
362 fn __interrupt_mode_pender(interrupt: OpaqueInterruptContext); 362 fn __interrupt_mode_pender(interrupt: OpaqueInterruptContext);
363 } 363 }
364 unsafe { __interrupt_mode_pender(interrupt) }; 364 unsafe { __interrupt_mode_pender(interrupt) };
365 } 365 }
366 #[cfg(feature = "pender-callback")] 366 #[cfg(feature = "pender-callback")]
367 PenderInner::Callback { func, context } => func(context), 367 Pender::Callback { func, context } => func(context),
368 } 368 }
369 } 369 }
370} 370}