MessageThread and callFunctionOnMessageThread


#1

I have a background thread which reads audio-data.
Because of Quicktime-Audioformat i have to create the Audioreader on the Message-Thread, so i use callFunctionOnMessageThread().
If i stop this background thread from the message-thread i may have a classic deadlock situation.
It would be nice to have a Thread::stopThread() variant which also dispatch the messageThread instead of sleep, and preserves that no other new GUI-actions are triggered.


#2

Yes, that’s a tricky situation. I think I got around the same problem by making the thread send a CallbackMessage that loaded the file, and then the thread sat waiting (checking its threadShouldExit flag) until the message had completed.