alloy-rs / alloy

Transports, Middleware, and Networks for the Alloy project
https://alloy.rs
Apache License 2.0
653 stars 236 forks source link

fix: wrap dashmap in Arc #1624

Closed mattsse closed 2 weeks ago

mattsse commented 2 weeks ago

ref #1491

dashmap is clone, which imo is a footgun, because dashmap acts as Rwlock<HashMap> not Arc<Rwlock<HashMap>>

DashMap tries to be very simple to use and to be a direct replacement for RwLock<HashMap<K, V>>. To accomplish this, all methods take &self instead of modifying methods taking &mut self. This allows you to put a DashMap in an Arc and share it between threads while being able to modify it.