I'm trying to write code that requires some basic locking that compiles with
std. For that I'm looking for a Mutex trait implementation that I can either implement myself (e.g. with a spinlock) for
no_std and that already has an implementation for
I've found mutex-trait, which is very close, but doesn't have an implementation for
std::sync::Mutex. It's also inconvenient, because it requires a mutable reference to be used, which breaks the usual
Am I missing something?
You can always implement it on your behalf.
You might also want to look into the
lock_api crate, which contains the underlying traits used by
parking_lot, a popular alternative to
See here for an explanation of this design decision.
I found this quite unintuitive, but there seems to be a simple solution as described in the RFC. The only thing missing there is that
Mutex<T> has to implement
Sync. This might not be the case with RTIC, but in general it's necessary at least for statics (I think).
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.