I'm developing an audio application, where the (realtime) Audio thread and the GUI thread communicate via a ReaderWriterQueue. I have a queue containing objects of type PitchCurveUpdateMessage, which has a field of type std::vector<std::pair<int, ClientsidePitchData>>.
I populate the vector in the GUI thread, wrap it in a PitchCurveUpdate object and send it over to the Audio thread via queue.try_enqueue.
On the audio thread, I have a function called fetch(), which calls try_dequeue, providing a pre-allocated PitchCurveUpdateMessage as the target object to avoid memory allocation. To me, this seems like basic usage of the ReaderWriterQueue, however, XCode 10's ThreadSanitizer reports a data race in my code (see below).
Is there anything I'm missing when working with std::vectors? Do I need to protect them in any special way? Are vectors not suitable for use in a ReaderWriterQueue, as they allocate their own heap memory?
Thanks in advance for any help!
I'm developing an audio application, where the (realtime) Audio thread and the GUI thread communicate via a
ReaderWriterQueue. I have a queue containing objects of typePitchCurveUpdateMessage, which has a field of typestd::vector<std::pair<int, ClientsidePitchData>>.I populate the vector in the GUI thread, wrap it in a
PitchCurveUpdateobject and send it over to the Audio thread viaqueue.try_enqueue.On the audio thread, I have a function called
fetch(), which callstry_dequeue, providing a pre-allocatedPitchCurveUpdateMessageas the target object to avoid memory allocation. To me, this seems like basic usage of theReaderWriterQueue, however, XCode 10's ThreadSanitizer reports a data race in my code (see below).Is there anything I'm missing when working with
std::vectors? Do I need to protect them in any special way? Are vectors not suitable for use in aReaderWriterQueue, as they allocate their own heap memory?Thanks in advance for any help!