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.