-
Notifications
You must be signed in to change notification settings - Fork 21
Implement a proc-macros threads creation #83
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: main
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.
I like it
/// | ||
/// Will block until the thread has terminated. | ||
/// | ||
/// TODO: Allow a timeout? |
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.
It would be smart to allow a timeout and return the integer result.
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.
Actually, would it make more sense to do something similar to what std::thread
does where we return a Result that can be either Ok or an Err? I guess that's more "rustonic" than integer return values 😅
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 handling the timeout is a reasonable request. The Result will be Rust-y. But, thinly wrapped.
Allow an explicit timeout to be given to join, replacing the implementation of the blocking one to one that calls it with a Forever timeout. Signed-off-by: David Brown <[email protected]>
Replace how Zephyr threads are declared in Rust. Provides a proc-macro to make this fairly straightforward:
This function can then be called, and will return a
ReadThread
. This has methods for setting priority, and astart
method, which returns aRunningThread
, which has a join method. The thread can be respawned after it has exited.The thread macro also accepts a
pool_size = nnn
parameter, which will create an array of threads, and can be started that many times.