-
Notifications
You must be signed in to change notification settings - Fork 6
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
single-thread
feature for removing ELF TLS dependency
#1
base: master
Are you sure you want to change the base?
Conversation
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.
Looking good!
Just a couple things:
-
I'd like the name of the feature to be named "unsafe-single-thread". This is because using that feature in a multi-threaded environment will lead to memory unsafety, and I want to make sure the user is aware of that and properly reads the documentation.
-
There's an important catch when it comes to embedded usage: Interrupts counts as a separate thread as well! So "running your code on a microcontroller that has only a single processor is an
easy way of guaranteeing that the single-thread contract is upheld." is wrong, and I think should be specifically called out that interrupts are considered their own thread and shouldn't be using await.
I added a warning about not polling futures from an interrupt routine. However, are interrupts actually a problem so long as they occur on the same core? I get that the TLS_CX variable wouldn't be automatically restored by the CPU itself when the interrupt returns, but the Example timeline:
Even interrupts within interrupts or chained interrupts would succeed due to to the SetOnDrop logic, right? |
Adds a new feature
single-thread
which when activated removes the#[thread_local]
dependency. The catch is that the user must guarantee that futures will never be polled from more than one thread.I intend to use this support to allow me to run futures on a STM32F103 board which only has a single core, so the only-one-thread limitation is not a problem. In general I expect this feature to only be used to target similar embedded systems.