Skip to content

Deprecate old async #65

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

Closed
wants to merge 3 commits into from
Closed

Deprecate old async #65

wants to merge 3 commits into from

Conversation

d3zd3z
Copy link
Collaborator

@d3zd3z d3zd3z commented Mar 5, 2025

Begin the process of deprecating the old "async" implementation. This implementation has numerous problems:

  • It is fundamentally incompatible with how async executors are expected to work. Trying to combine with other libraries that expect async will either result in a panic, or even undefined behavior.
  • They are only usable with a limited set of scheduling primitives, notably Zephyr's k_sem, and k_queue. This is largely a limitation of what is supported by triggered in Zephyr.
  • They're not useful for much else. In order to work with something like a driver callback, that interface would have to use a Semaphore or Channel, since the Waker from the async call itself cannot be used.
  • They aren't very efficient. Using triggered work ends up using the combined overhead of threads, and work queues. Using the utilities provided by Embassy allows same-thread scheduling to be very low overhead, while bringing in the thread scheduling overhead only when wakes will cross thread boundaries.

The proposed alternative is to use the Executor provided by the feature executor-zephyr. This is a very lightweight executor, making use of some utilities provided by Embassy to allow lightweight scheduling on a single thread, and reasonably efficient scheduling across Zephyr threads. Async device operations can use the Waker mechanism as designed to be able to provide nice async Rust interfaces to drivers.

@d3zd3z d3zd3z force-pushed the deprecate-old-async branch from 6bf3b19 to 18220ea Compare March 5, 2025 22:37
d3zd3z added 3 commits March 7, 2025 12:41
In preparation to deprecate some of the APIs, bump the crate version so
that the deprecation annotation has a version to apply to.

Signed-off-by: David Brown <[email protected]>
This work-queue based async executor, although functional, has some
significant problems. Most notably, it doesn't use wakers, and as such,
is incompatible with other utilities that have been written to be used
with Async.  Trying to combine them will, in fact, result in undefined
behavior.

Now that the embassy-based executor-zephyr is in main, mark these as
deprecated so that code can gradually move to newer solutions.

Signed-off-by: David Brown <[email protected]>
During the transition through deprecation of the old async code, allow
references to it to remain in the samples.  These can be gradually
transitioned to newer solutions.

Signed-off-by: David Brown <[email protected]>
@d3zd3z d3zd3z force-pushed the deprecate-old-async branch from 18220ea to c518a99 Compare March 7, 2025 19:41
Copy link

@teburd teburd left a comment

Choose a reason for hiding this comment

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

I'd simply drop it unless something depends on this

@d3zd3z
Copy link
Collaborator Author

d3zd3z commented Mar 14, 2025

Instead of deprecating these, I'll go ahead and just drop the support.

@d3zd3z d3zd3z closed this Mar 14, 2025
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.

3 participants