and the swap (caused by messageFlipRequested later in the Engine, on the producer side) occurs twice before I currently read the whole *message on the “slow” thread?
Is it correct to state that in this case I could read parts of the *message written in different process()'s call?
Such as:
audio thread write buffer A
gui thread take the pointer of A (message)
swap occurs (=>B)
audio thread write to buffer B
gui thread read 1/2 of the arrays of A and than will be stopped by other “main thread”
swap happens again (=>A)
audio thread write again to A
gui thread will be reactivated, reading the other half of the array A with new values
You are guaranteed to have exclusive access to your expander message during Module::process() and nowhere else. If you want to use a thread to send expander messages, you’ll need to send data to Module in a thread-safe way, and then copy that data to the producerMessage in Module::process(). For receiving expander messages on another thread, do the reverse.
I would like to replicate the same mechanism for sharing and sync data from audio to gui thread, but it will fail without an appropriate management of concurrency.
Whenever I want to send „messages“ from the DSP thread to the GUI thread I use dsp::RingBuffer which is thread-safe for single producer and single consumer. It also helps for enqueuing multiple messages as the GUI runs „slower“.