Skip to content
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

feat(threads): delay thread start until init_task() has finished #526

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kaspar030
Copy link
Collaborator

@kaspar030 kaspar030 commented Nov 14, 2024

Description

This PR adds infra to make threads wait for system initialization (riot_rs_embassy::init_task()) to complete before starting.

This makes some code easier, e.g.,

Basically, it allows threads to assume a sane system state.

Issues/PRs references

See also #509.

Open Questions

Change checklist

  • I have cleaned up my commit history and squashed fixup commits.
  • I have followed the Coding Conventions.
  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.

@@ -49,6 +49,13 @@ pub mod macro_reexports {
pub use static_cell;
}

#[doc(hidden)]
pub mod _events {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub mod _events {
pub mod events {

_foo means that it's unused, not that it is private or "not to be used by users"

_ => panic!(r#"neither "riot-rs" nor "riot-rs-threads" found in dependencies!"#),
}
};

let expanded = quote! {
#no_mangle_attr
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#no_mangle_attr
#no_mangle_attr
#[inline(always)]

Not saying that I know better than the compiler, but maybe in this case it can be useful, so that it gets inlined inside the trampoline function?

#[doc(hidden)]
pub mod _events {
use crate::sync::Event;
// this is set in `riot_rs_embassy::init_task()``
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// this is set in `riot_rs_embassy::init_task()``
// this is set in `riot_rs_embassy::init_task()`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants