title: When do I need a lock-free data structure for reading/writing data across threads in audio apps?
body: <p>My scenario is something like: User interacts with GUI elements, audio callback function reads variables set by the UI, calculates samples and stores samples in a buffer (or whatever data-structure), buffer is then read  by the UI and draws a wave form (in a draw loop 60 times per second). </p>
  
  <p>Now, according to some stuff I've read (a thread in the Linux audio dev list, <a href="http://www.rossbencina.com/code/lockfree" rel="noreferrer">this</a> and <a href="http://portaudio.com/docs/v19-doxydocs-dev/pa__ringbuffer_8h.html" rel="noreferrer">this</a>) I need some sort of data structure that can be read and written simultaneously without requiring a lock, or, I need some sort of cross-thread notification system to pass variables around.</p>
  
  <p>However, <a href="https://github.com/openframeworks/openFrameworks/tree/master/apps/examples/audioInputExample" rel="noreferrer">some</a> <a href="https://github.com/openframeworks/openFrameworks/tree/master/apps/examples/audioOutputExample" rel="noreferrer">examples</a> I've seen use vanilla vectors from the C++ std library, they read from one thread and write from the other and when I run the programs, they run fine.</p>
  
  <ol>
  <li>In which cases do I need to use a lock free data structure do do this sort of cross-thread communication? </li>
  <li>If I add another thread such as a MIDI or OSC callback function that receives network IO and needs to pass data to the other two threads, do I need to worry about lock-free structures? </li>
  <li>Which would be an adequate structure to use if answer to number two is "yes"?  </li>
  </ol>