Search Unity

Multi-producer, single consumer hashset

Discussion in 'Entity Component System' started by PublicEnumE, Nov 22, 2019.

  1. PublicEnumE

    PublicEnumE

    Joined:
    Feb 3, 2019
    Posts:
    729
    What's the best DOTS option for a Hashset which can be written to from a single job on multiple threads?

    I've seen people suggesting home-spun Native hashset collections, but it's unclear if those are still supported, or if they support writing the same hash value from multiple threads.

    Elsewhere, people have suggested using a NativeMultiHashMap, then grabbing its keys. But that solution will result in multiple key entries. While not hard to work around, NativeMultiHashMap.GetKeyArray() can also be an expensive call.

    What would you recommend is the best solution, here at the end of 2019?
    Thank you for any advice.
     
    Last edited: Nov 22, 2019
  2. Deleted User

    Deleted User

    Guest

  3. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
    NativeHashMap with empty struct as value (yeah is still 1 byte even if struct empty) it’s just simpler solution. Or write your own HashSet like from blog above.