Skip to content

about a concurrency operation issue #248

Closed
@littledoglily

Description

@littledoglily

"I have a background thread which consumes Kafka messages and then writes them into a parallel_flat_hash_map. Other threads execute find operations. I really want to know if the parallel_flat_hash_map must be protected by a mutex. In our system, we define the map like this: using LocalMap = phmap::parallel_flat_hash_map<uint64_t, std::array<float, N>>, which uses the default NullMutex, and we have not experienced any core dumps or segmentation faults.

However, in the README, I found the following statement: 'If a single hash table is being written to by one thread, then all reads and writes to that hash table on the same or other threads must be protected. For example, given a hash table A, if thread 1 is writing to A, then thread 2 must be prevented from reading from or writing to A.'

I have some confusion, and I am not entirely sure if I understand correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions