Hi all, I've been spending my holidays watching cricket and thinking about exchanging data between threads. What I'm struggling with is is that lock-free queues are good for single producer/single consumer scenarios, yet when communicating from AudioProcessor to AudioProcessorEditor we need to cater for the possibility that there may be multiple editors. The following options occur to me:
- Only communicate POD values atomically - but I'd like to be able to deliver FFT data for example
- Don't worry about data tearing (e.g. don't worry if processor updates FFT data array mid-way through GUI draw)
- Only allow one editor to read from the queue - problem with this is you don't necessarily know which editor is going to be shown by the host
- Design a single producer/multi consumer FIFO
- Lock-free FIFO to transmit to a dispatcher (aka relay) on the message thread, which in turn makes data available to multiple editors (can use locks here)
The fourth one would be ideal, but I reckon it's not straightforward. So I'm wondering what Timur, Jules (or anyone else) can suggest?
Edited to add option 5