-
Notifications
You must be signed in to change notification settings - Fork 242
Add local tasks #1108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add local tasks #1108
Changes from 5 commits
5bb3ba9
f10d2b9
8fbf8a9
355b478
518dfae
d9fe447
1e8c175
025460b
5e658e4
96b5a81
266ddd1
f5e8694
09598ad
a599039
7f1521b
7f7c0d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #![no_main] | ||
| #![no_std] | ||
|
|
||
| use core::marker::PhantomData; | ||
| use rtic::app; | ||
| use {defmt_rtt as _, panic_probe as _}; | ||
| pub mod pac { | ||
| pub use embassy_stm32::pac::Interrupt as interrupt; | ||
| pub use embassy_stm32::pac::*; | ||
| } | ||
|
|
||
| #[app(device = pac, peripherals = false, dispatchers = [SPI1])] | ||
| mod app { | ||
| use super::*; | ||
|
|
||
| #[shared] | ||
| struct Shared {} | ||
|
|
||
| #[local] | ||
| struct Local {} | ||
|
|
||
| #[init] | ||
| fn init(_cx: init::Context) -> (Shared, Local) { | ||
| task1::spawn().ok(); | ||
| //task2::spawn(Default::default()).ok(); <--- This is rejected since it is a local task | ||
| (Shared {}, Local {}) | ||
| } | ||
|
|
||
| #[task(priority = 1)] | ||
| async fn task1(cx: task1::Context) { | ||
| defmt::info!("Hello from task1!"); | ||
| cx.local_spawner.task2(Default::default()).ok(); | ||
| } | ||
|
|
||
| #[task(priority = 1, is_local_task = true)] | ||
| async fn task2(_cx: task2::Context, _nsns: super::NotSendNotSync) { | ||
| defmt::info!("Hello from task1!"); | ||
| } | ||
| } | ||
|
|
||
| #[derive(Default)] | ||
| struct NotSendNotSync(PhantomData<*mut u8>); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #![no_main] | ||
|
|
||
| #[rtic_macros::mock_app(device = mock, dispatchers = [EXTI0])] | ||
| mod app { | ||
| use super::*; | ||
|
|
||
| #[shared] | ||
| struct Shared {} | ||
|
|
||
| #[local] | ||
| struct Local {} | ||
|
|
||
| #[init] | ||
| fn init(_cx: init::Context) -> (Shared, Local) { | ||
| (Shared {}, Local {}) | ||
| } | ||
|
|
||
| #[task(priority = 1, is_local_task = true)] | ||
|
||
| async fn foo(_cx: foo::Context) {} | ||
|
|
||
| #[task(priority = 2)] | ||
| async fn bar(cx: bar::Context) { | ||
| cx.local_spawner.foo().ok(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #![no_main] | ||
|
|
||
| #[rtic_macros::mock_app(device = mock, dispatchers = [EXTI0])] | ||
| mod app { | ||
| use super::*; | ||
|
|
||
| #[shared] | ||
| struct Shared {} | ||
|
|
||
| #[local] | ||
| struct Local {} | ||
|
|
||
| #[init] | ||
| fn init(_cx: init::Context) -> (Shared, Local) { | ||
| foo::spawn().ok(); | ||
| (Shared {}, Local {}) | ||
| } | ||
|
|
||
| #[task(priority = 1, is_local_task = true)] | ||
| async fn foo(_cx: foo::Context) {} | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an unrelated formatting change, or am I missing a functionality change here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you like me to revert this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, yes. If you submit it as a separate PR I can force-merge it, while getting rid of this thing bugging you