I use a Map where the value needs to be protected on access. In particular I use crossbeam SkipMap. However I could have potentially 100s of thousands of items in the map. My question is would the following definition make sense:
let map : SkipMap<String, RwLock<MyDataType>> = SkipMap::new();
Things work but I am suspicious about using 100s of thousands of RwLocks. For instance in Java or in C++ I would have an abstraction that pools say N RwLocks, from which I could get one lock via a hash scheme to protect access. Is there any way to achieve that in Rust? Is it ok to have 100s of thousands of lock instances?
parking_lot's RwLock may be more suitable for you. The "parking lot" abstraction was designed specifically to make it relatively cheap to have a lot of locks without relying on platform specific implementation details.