nikita-volkov / stm-containers

Containers for STM
http://hackage.haskell.org/package/stm-containers
MIT License
66 stars 13 forks source link

Starvation-free iteration? #32

Open 414owen opened 1 year ago

414owen commented 1 year ago

Hello @nikita-volkov,

I have an StmContainers.Map, which I mostly lookup from and insert to.

Occasionally, I have to iterate over the entire map.

As the branches of the HAMT are TVars, I'm guessing the listT operation is subject to a retry, if anything changes in the map while iterating?

This probably means the iteration operation will be starved, in my current setup.

Do you think it's possible to add a non-transactional iteration in IO to StmContainers.Map, or do you think I should be using a TVar (Hashmap k v) instead?

nikita-volkov commented 1 year ago

Hi! Sounds like a reasonable observation. I'm open to merge a PR which would add such a function.