title: c++11 share fixed size array between different classes
body: <p>I'm working with on real-time application divided in two parts (threads):<br></p>
  
  <ul>
  <li>processing</li>
  <li>graphics</li>
  </ul>
  
  <p>the output of processing is an array of fixed size (of <code>float</code>) and to maintain a real-time performance I want to send such data to another thread that will draw, for example graphs, at its own pace. <br>
  I've looked into <code>atomic</code> and <code>lock</code> but I can't figure out how to make the application thread-safe given that the two processes are completely independent.
  <br><br>
  Sample code:<br></p>
  
  <pre><code>class A {
      float data[n];
      processData() {
          data = ... ;
      }
  }
  
  class B {
      void draw() {
          // requires data[] from class A
      }
  }
  </code></pre>
  
  <p>Both classes are initialized in the main thread and I've tried to define a <code>float*</code> pointer there and pass it to the other two threads, processing assigns it to <code>data[]</code> and graphics is able to read it but there's obviously errors when one is reading and the other is modifying it at the same time.</p>