mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-27 01:02:37 +00:00
80972f1e0e
This is a `core` patch to make wakers 1 word (the task pointer) instead of 2 (task pointer + vtable). It allows having the "waker optimization" we had a while back on `WakerRegistration/AtomicWaker`, but EVERYWHERE, without patching all crates. Advantages: - Less memory usage. - Faster. - `AtomicWaker` can actually use atomics to load/store the waker, No critical section needed. - No `dyn` call, which means `cargo-call-stack` can now see through wakes. Disadvantages: - You have to patch `core`... - Breaks all executors and other things that create wakers, unless they opt in to using the new `from_ptr` API. How to use: - Run this shell script to patch `core`. https://gist.github.com/Dirbaio/c67da7cf318515181539122c9d32b395 - Enable `build-std` - Enable `build-std-features = core/turbowakers` - Enable feature `turbowakers` in `embassy-executor`, `embassy-sync`. - Make sure you have no other crate creating wakers other than `embassy-executor`. These will panic at runtime. Note that the patched `core` is equivalent to the unpached one when the `turbowakers` feature is not enabled, so it should be fine to leave it there. |
||
---|---|---|
.. | ||
src | ||
build.rs | ||
Cargo.toml | ||
README.md |
embassy-sync
An Embassy project.
Synchronization primitives and data structures with async support:
Channel
- A Multiple Producer Multiple Consumer (MPMC) channel. Each message is only received by a single consumer.PubSubChannel
- A broadcast channel (publish-subscribe) channel. Each message is received by all consumers.Signal
- Signalling latest value to a single consumer.Mutex
- Mutex for synchronizing state between asynchronous tasks.Pipe
- Byte stream implementingembedded_io
traits.WakerRegistration
- Utility to register and wake aWaker
.AtomicWaker
- A variant ofWakerRegistration
accessible using a non-mut API.MultiWakerRegistration
- Utility registering and waking multipleWaker
's.
Interoperability
Futures from this crate can run on any executor.
Minimum supported Rust version (MSRV)
Embassy is guaranteed to compile on the latest stable Rust version at the time of release. It might compile with older versions but that may change in any new patch release.
License
This work is licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.