embassy
embassy copied to clipboard
Makes our various mutexes available to Signal
Embassy provides various types of Mutex e.g. Noop. This PR allows the mutex to be provided as per what we do with the MPSC. A major benefit is that the previous situation of needing a critical section can often be avoided.
A consequence of the change is that the new function is no longer const. This means that, as per the MPSC, Forever needs to be utilised e.g.:
static SOME_SIGNAL: Forever<Signal<Noop, SomeCommand>> = Forever::new();
// Then, during initialization...
let some_signal = SOME_SIGNAL.put(Signal::new());
This might need rebasing now that https://github.com/embassy-rs/embassy/pull/792 is merged as it uses a Signal.
Just writing up here what became the blocker: Functions in traits cannot be declared const...
The RFC states:
Traits, trait implementations and their methods cannot be const - this allows us to properly design a constness/CTFE system that interacts well with traits - for more details, see Alternatives.
I'm unsure that there's a way forward here.
Done in #961