-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(threads): introduce a declarative macro for autostarting threads (…
- Loading branch information
Showing
6 changed files
with
32 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/// Starts the `fn_name` function in a dedicated thread at startup. | ||
/// | ||
/// The thread is given a `stacksize`-byte stack, and has priority `priority`. | ||
#[macro_export] | ||
macro_rules! autostart_thread { | ||
($fn_name:ident, stacksize = $stacksize:literal, priority = $priority:literal) => { | ||
$crate::macro_reexports::paste::paste! { | ||
#[$crate::macro_reexports::linkme::distributed_slice($crate::THREAD_FNS)] | ||
#[linkme(crate = $crate::macro_reexports::linkme)] | ||
fn [<__start_thread_ $fn_name>] () { | ||
let stack = $crate::macro_reexports::static_cell::make_static!([0u8; $stacksize as usize]); | ||
$crate::thread_create_noarg($fn_name, stack, $priority); | ||
} | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters