ibraheemdev / papaya

A fast and ergonomic concurrent hash-table for read-heavy workloads.
MIT License
343 stars 5 forks source link

Persistent State for `HashMap::compute` #9

Open ibraheemdev opened 2 months ago

ibraheemdev commented 2 months ago

Currently HashMap::compute requires an FnMut and has no way of persisting state. For example, inserting a V requires cloning if the operation fails and is retried. Internally we memoize all inserts to avoid this, but that's a hack that shouldn't be expose to users. Instead we might want to provide an on_failure(Operation<V>) hook to allow state to be reset. I don't want the API to become convoluted, so maybe just guaranteeing that inserts are memoized is simpler?