aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/raw
diff options
context:
space:
mode:
authorDániel Buga <[email protected]>2023-08-14 08:57:14 +0200
committerDániel Buga <[email protected]>2023-08-14 09:00:08 +0200
commitf6007869bffd3ed4f48e74222dc40d11c7c87ec0 (patch)
treebd8e1afe8d0a959a52ddcb75bdc30988a7d1615e /embassy-executor/src/raw
parent454a7cbf4c0eb3a4e651e7da5512ec49ff7d4050 (diff)
Remove the Pender enum
Diffstat (limited to 'embassy-executor/src/raw')
-rw-r--r--embassy-executor/src/raw/mod.rs48
1 files changed, 7 insertions, 41 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs
index 81ad1e53d..a0a940e25 100644
--- a/embassy-executor/src/raw/mod.rs
+++ b/embassy-executor/src/raw/mod.rs
@@ -292,54 +292,20 @@ impl<F: Future + 'static, const N: usize> TaskPool<F, N> {
292} 292}
293 293
294/// Context given to the thread-mode executor's pender. 294/// Context given to the thread-mode executor's pender.
295#[repr(transparent)] 295pub type PenderContext = usize;
296#[derive(Clone, Copy)]
297pub struct OpaqueThreadContext(pub(crate) usize);
298
299/// Context given to the interrupt-mode executor's pender.
300#[derive(Clone, Copy)]
301#[repr(transparent)]
302pub struct OpaqueInterruptContext(pub(crate) usize);
303 296
304/// Platform/architecture-specific action executed when an executor has pending work.
305///
306/// When a task within an executor is woken, the `Pender` is called. This does a
307/// platform/architecture-specific action to signal there is pending work in the executor.
308/// When this happens, you must arrange for [`Executor::poll`] to be called.
309///
310/// You can think of it as a waker, but for the whole executor.
311#[derive(Clone, Copy)] 297#[derive(Clone, Copy)]
312pub enum Pender { 298pub(crate) struct Pender(PenderContext);
313 /// Pender for a thread-mode executor.
314 #[cfg(feature = "executor-thread")]
315 Thread(OpaqueThreadContext),
316
317 /// Pender for an interrupt-mode executor.
318 #[cfg(feature = "executor-interrupt")]
319 Interrupt(OpaqueInterruptContext),
320}
321 299
322unsafe impl Send for Pender {} 300unsafe impl Send for Pender {}
323unsafe impl Sync for Pender {} 301unsafe impl Sync for Pender {}
324 302
325impl Pender { 303impl Pender {
326 pub(crate) fn pend(self) { 304 pub(crate) fn pend(self) {
327 match self { 305 extern "Rust" {
328 #[cfg(feature = "executor-thread")] 306 fn __pender(context: PenderContext);
329 Pender::Thread(core_id) => {
330 extern "Rust" {
331 fn __thread_mode_pender(core_id: OpaqueThreadContext);
332 }
333 unsafe { __thread_mode_pender(core_id) };
334 }
335 #[cfg(feature = "executor-interrupt")]
336 Pender::Interrupt(interrupt) => {
337 extern "Rust" {
338 fn __interrupt_mode_pender(interrupt: OpaqueInterruptContext);
339 }
340 unsafe { __interrupt_mode_pender(interrupt) };
341 }
342 } 307 }
308 unsafe { __pender(self.0) };
343 } 309 }
344} 310}
345 311
@@ -499,9 +465,9 @@ impl Executor {
499 /// When the executor has work to do, it will call the [`Pender`]. 465 /// When the executor has work to do, it will call the [`Pender`].
500 /// 466 ///
501 /// See [`Executor`] docs for details on `Pender`. 467 /// See [`Executor`] docs for details on `Pender`.
502 pub fn new(pender: Pender) -> Self { 468 pub fn new(context: PenderContext) -> Self {
503 Self { 469 Self {
504 inner: SyncExecutor::new(pender), 470 inner: SyncExecutor::new(Pender(context)),
505 _not_sync: PhantomData, 471 _not_sync: PhantomData,
506 } 472 }
507 } 473 }