Skip to content

In the LF_Queue, the getWriteIndex() might not be thread safe #4

@sowgali

Description

@sowgali

In lf_queueu.h, the following function might not be thread-safe because the updateWriteIdx() is called after calling getNextToWriteTo()

auto getNextToWriteTo() noexcept {
      return &store_[next_write_index_];
}

This might lead to two threads accessing the same write location. The same thing applies to reads as well. Let me know if there is anything wrong with my understanding. Should we use a CAS-based lock-free queue, however, it will have to spin. Or we should atomically increment the next_write_index_ with modulus.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions