Hello,
I am trying to program a device that will have MIDI as an input. The device will run multiple threads, some will be interested in the MIDI input, some won't. The threads that are interested in the MIDI messages will process the incoming information, each in a different way. What do you think would be the best way to make sure that all the threads will receive all the incoming MIDI messages, in the order they were received by the MIDI interface?
Deliver the same message queue to many threads
Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess
-
- Posts: 8
- Joined: Sun Nov 14, 2021 8:44 pm
- Has thanked: 2 times
- Been thanked: 1 time
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: Deliver the same message queue to many threads
Hi,
You could post messages on multiple Mailboxes (or Object FIFOs if you need to exchange complex messages), one for each thread that can consume messages.
On the receiving side, threads would always consume messages from their own Mailbox and decide, locally, if process it or discard it.
Giovanni
You could post messages on multiple Mailboxes (or Object FIFOs if you need to exchange complex messages), one for each thread that can consume messages.
On the receiving side, threads would always consume messages from their own Mailbox and decide, locally, if process it or discard it.
Giovanni
-
- Posts: 8
- Joined: Sun Nov 14, 2021 8:44 pm
- Has thanked: 2 times
- Been thanked: 1 time
-
- Posts: 8
- Joined: Sun Nov 14, 2021 8:44 pm
- Has thanked: 2 times
- Been thanked: 1 time
Re: Deliver the same message queue to many threads
Follow-up question: what if the number of the threads interested in processing the messages wasn't static, but could change at run time?
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: Deliver the same message queue to many threads
You need to decide the maximum number and allocate that amount of mailboxes.
Giovanni
Giovanni
Who is online
Users browsing this forum: No registered users and 10 guests