Understanding Messages


is it correct, that Messages could only be “sent” to the same instance of MessageListener?
Found that in juce_MessageListener.h:

void MessageListener::postMessage (Message* const message) const
    message->recipient = const_cast<MessageListener*> (this);

If I want to use that system to share messages between two threads, both threads must know the same instance of MessageListener, right?
What else can I use in order to send messages from one thread to another one. Is there anything existing, where I can send messages to multiple receivers? Or better: where a receiver can specify via an ID which message can be received.


Hello again,

does anybody have a hint for me? :innocent:


Hi Mike-

The JUCE Message class is intended for sending messages to the application’s primary event loop. It’s not really useful for communication between background threads. I recommend you dig into the MessageManager for more information.


I don’t think JUCE has anything specifically for inter-thread communication. You might be able to use the InterprocessConnection class, but that’s really meant for messaging between different processes, as the name suggests.