Mutex/spinlock/condvar by wedsonaf · Pull Request #990 · Rust-for-Linux/linux (original) (raw)
I agree, I don't like it either. (And we talked about this effect in the context of Arc
in some past meeting.)
However, the split of lock backend/frontend really simplifies how we implement other locks: we don't need to reimplement the struct with the C lock + unsafe cell for data + phantom pinned data, Deref
implementations, etc. We already have two locks in this series, and we'll have more soon (e.g., RawSpinLock).
One thing we could perhaps do is to create a new type with a Deref
implementation, but it goes against the recommendation in its documentation:
Deref should only be implemented for smart pointers to avoid confusion.
So I think for now we should take this small hit on usability when the wrong type is supplied. Unless, of course, you have better ideas on how to improve this.