aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor-macros/src/lib.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-04-07 13:08:33 +0000
committerGitHub <[email protected]>2025-04-07 13:08:33 +0000
commit1eec9646371dc4571dfe841a6cbab4db9211f7bb (patch)
treeccc151d3aa089703c77099d01b8f2e6bf4da2144 /embassy-executor-macros/src/lib.rs
parentcb4d8c74c2b07de7c32be588140512bdd4d3f47e (diff)
parentef8d168df6fa1d8020d7490e4469d196a35077ce (diff)
Merge pull request #4046 from outfoxxed/main-macro-executor
executor: add executor selection to #[embassy_executor::main]
Diffstat (limited to 'embassy-executor-macros/src/lib.rs')
-rw-r--r--embassy-executor-macros/src/lib.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/embassy-executor-macros/src/lib.rs b/embassy-executor-macros/src/lib.rs
index 5f2182f10..8e737db6a 100644
--- a/embassy-executor-macros/src/lib.rs
+++ b/embassy-executor-macros/src/lib.rs
@@ -173,3 +173,27 @@ pub fn main_std(args: TokenStream, item: TokenStream) -> TokenStream {
173pub fn main_wasm(args: TokenStream, item: TokenStream) -> TokenStream { 173pub fn main_wasm(args: TokenStream, item: TokenStream) -> TokenStream {
174 main::run(args.into(), item.into(), &main::ARCH_WASM).into() 174 main::run(args.into(), item.into(), &main::ARCH_WASM).into()
175} 175}
176
177/// Creates a new `executor` instance and declares an application entry point for an unspecified architecture, spawning the corresponding function body as an async task.
178///
179/// The following restrictions apply:
180///
181/// * The function must accept exactly 1 parameter, an `embassy_executor::Spawner` handle that it can use to spawn additional tasks.
182/// * The function must be declared `async`.
183/// * The function must not use generics.
184/// * Only a single `main` task may be declared.
185///
186/// A user-defined entry macro and executor type must be provided via the `entry` and `executor` arguments of the `main` macro.
187///
188/// ## Examples
189/// Spawning a task:
190/// ``` rust
191/// #[embassy_executor::main(entry = "your_hal::entry", executor = "your_hal::Executor")]
192/// async fn main(_s: embassy_executor::Spawner) {
193/// // Function body
194/// }
195/// ```
196#[proc_macro_attribute]
197pub fn main_unspecified(args: TokenStream, item: TokenStream) -> TokenStream {
198 main::run(args.into(), item.into(), &main::ARCH_UNSPECIFIED).into()
199}