cats-effect
cats-effect copied to clipboard
Default constructor for `MapRef`
We currently have many MapRef implementations, based on Ref[Map], sharding, ConcurrentHashMap, etc. We should have an apply constructor that chooses a reasonable default implementation, probably ConcurrentHashMap.
@armanbilge I'd like to pick this up
@BalmungSan raised a good point that this default constructor should only require a Concurrent constraint. We can pattern-match for Async to use ConcurrentHashMap implementation, otherwise maybe we can fallback to the sharded Ref[Map] with the number of shards determined by the number of processors.
While we're at it, a nicer API for defaultedMapRef would also be welcome. E.g. a constructor that directly takes a default value, or an instance method on trait MapRef. MapRefOptionOps is probably a good place for it too.
MapRefOptionOpsis probably a good place for it too.
Yes, I think this would be my vote. I think should be easy to chain with the constructor as well so we won't need a separate constructor?