Recently, I was in need of an implementor of lock_api::RawMutex and I was surprised to find that there is no implementation based on std available. Indeed, I could not find any suitable implementation at all and had to cobble together my own futex based lock. This of course limits portability.
I looked at these options:
spin: I sometimes use a cooperative thread scheduler (hermit), so this does not workparking_lot: This allocates. I plan to use the mutex in an allocator (possibly the global allocator). So this also does not work.- implement in terms of
std: std only has the guard based api, so I cannot keep the mutex locked without storing the guard somewhere.
Basically, std implements a mutex exactly how I would want it, just with a too high level api. Therefore, my preferred solution would be for std to offer a more raw api for mutex so that lock_api could be implemented on top of it. What would be the process for making that happen?
All of this probably applies to RwLock as well, though I have not looked too far into that.