-
Notifications
You must be signed in to change notification settings - Fork 110
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
Create Macro to allow async fn main() #104
Conversation
- amend temperature example
- create cargo workspace - fix warnings
Why did you choose to use a procedural macro rather than implementing lang_items::Termination for |
I have no detailled knowledge about the Termination trait but I see two obstacles here:
|
I'm referring to this Line 35 in a8bb4fa
|
Good point! I added a commit on 103 to implement this and will close this one. |
…sync main()` function into a normal `main()` function. This is based on PR tock#104.
…n boards with no LED capsule. This breaks the existing support for `async` `main()` functions. Instead, an `async_main!()` macro is provided to generate a synchronous `main()` that wraps the provided `async` `main()` function (which, unfortunately, must not be called `main()`). This solves tock#111 and tock#113. I would prefer to be more consistent with Tokio and use a procedural macro attribute (as was originally done in tock#104), but I found that has some major drawbacks: 1. If main() does not parse, the error message does not point to the correct code. 2. It adds a requirement to update `syn` every time the toolchain is updated. These drawbacks are elaborated upon in tock#111.
…n boards with no LED capsule. This breaks the existing support for `async` `main()` functions. Instead, an `async_main!()` macro is provided to generate a synchronous `main()` that wraps the provided `async` `main()` function (which, unfortunately, must not be called `main()`). I would prefer to be more consistent with Tokio and use a procedural macro attribute (as was originally done in tock#104), but I found that has some major drawbacks: 1. If main() does not parse, the error message does not point to the correct code. 2. It adds a requirement to update `syn` every time the toolchain is updated. These drawbacks are elaborated upon in tock#111. This solves tock#111 and tock#113.
I re opened this pull request to have a base for discussion. (#115) |
merge after #103
Content of the PR
In this PR we add a proc macro attribute to allow creation of a
async fn main()
instead of a synchronousfn main()
. The advantage of this macro that the boilerplate code to create an async main function may be subject to breaking changes.Miscellaneous Changes
To simplify usage of the library all crates have been added to a workspace and the CI now also runs tests for the other crates in this repository.
Usage
For an example see the example
async.rs
.