embassy icon indicating copy to clipboard operation
embassy copied to clipboard

Makes our various mutexes available to Signal

Open huntc opened this issue 4 years ago • 2 comments
trafficstars

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());

huntc avatar Nov 22 '21 03:11 huntc

This might need rebasing now that https://github.com/embassy-rs/embassy/pull/792 is merged as it uses a Signal.

hydra avatar Jun 06 '22 23:06 hydra

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.

huntc avatar Jun 07 '22 00:06 huntc

Done in #961

Dirbaio avatar Sep 26 '22 18:09 Dirbaio