title: Looking for a lock-free RT-safe single-reader single-writer structure
body: <p>I'm looking for a <strong>lock-free design</strong> conforming to these requisites:</p>
  
  <ul>
  <li>a <strong>single writer</strong> writes into a structure and a <strong>single reader</strong> reads from this structure (this structure exists already and is safe for simultaneous read/write)</li>
  <li>but at some time, the structure needs to be <strong>changed by the writer</strong>, which then initialises, switches and writes into a new structure (of the same type but with new content)</li>
  <li>and at the next time the reader reads, it <strong>switches</strong> to this new structure (if the writer multiply switches to a new lock-free structure, the reader discards these structures, ignoring their data).</li>
  <li>The structures must be reused, i.e. no heap memory allocation/free is allowed during write/read/switch operation, for <strong>RT purposes</strong>.</li>
  </ul>
  
  <p>I have currently implemented a ringbuffer containing multiple instances of these structures; but this implementation suffers from the fact that when the writer has used all the structures present in the ringbuffer, there is no more place to change from structure... But the rest of the ringbuffer contains some data which don't have to be read by the reader but can't be re-used by the writer. As a consequence, the ringbuffer does not fit this purpose.</p>
  
  <p><strong>Any idea</strong> (name or pseudo-implementation) <strong>of a lock-free design?</strong> Thanks for having considered this problem.</p>