Sharing data structures in two threads of a piano roll


#1

I’m trying to build a piano roll connected to a vst as my final project for my engineer degree, but I’m having problems in the multithreading part. I split my piano roll in a GUI and an audio thread, and they share a list with the notes to be played. But I don’t know what’s the best solution to avoid races without using locks. I saw some papers where someone developed a lock free list (but it looks complex); or I thought in sharing a fifo buffer to notify changes and have two lists one in the GUI another in audio thread; and updating the one in the audio thread with a timer. 

Thanks in advance. 


#2

Hi!

There's a great lot to learn to do this right!

I got a great deal of help on this forum when I asked a similar question, here's the resulting thread(s), in order of usefulness to you:

http://www.juce.com/forum/topic/gui-unresponsive-even-through-cpu-cores-are-not-too-occupied-likely-i-need

http://www.juce.com/forum/topic/giving-value-component-eg-labelgettextvaluereferto-and-multithreading

http://www.juce.com/forum/topic/example-abstractfifo-referencecountedobject-objects