putIfAbsent callback

Issue #30 new
Sam Halliday created an issue

it would be fantastic if, e.g. putIfAbsent, was thread safe (and for the TPrimitiveObjectMap, even better if it took a callback instead of a value).

Comments (3)

  1. Rob Eden

    Trove collections follow the same model as the java.util Collections in that they are not thread safe (for performance) in their basic form and can be wrapped. In the same fashion, you can use TCollections.synchronizedMap to give you a map that is thread safe. We don't have an implementation analogous to ConcurrentMap, but it isn't necessary for this case.

    I like the callback idea. I'll keep the request open for that.

    Changing title from "concurrent versions" to "putIfAbsent callback"

  2. Sam Halliday reporter

    cool, thanks for looking at it. However, I would still urge you to consider a more specialised concurrent Map/Set. The Collections wrappers are very inefficient for larger collections, and that is exactly my use case. Efficiency can be gained through: write/lock lock protecting growing the table, and per-bucket hashes to protect collisions.

  3. Rob Eden

    Yeah, I understand the desire. It's not something I need, so it's more likely to happen with code contributions.

  4. Log in to comment