Inter-thread alternative to Boost message_queue

M

Max

Hi,

I'm developing a software using the great boost libraries. I need to
create many queue for allow different object running threads to
exchange messages between them in asyncronous mode. The message_queue
function is the best solution since allow to post a message into
another queue simply using the identification string. Currently, in my
implementation, each object create a message_queue identified with the
name of the object itself. Then create a thread remaining in wait for
new message. This allow objects to exchange messages using only the
name of the destination object. Very easy and very efficient.
"Unfortunately" I read in some post that this message_queue function is
made of interprocess communication and is not correct to use for
interthread communication. However what is the alternative?
Thank you

--
 
V

Vladimir Jovic

Max said:
Hi,

I'm developing a software using the great boost libraries. I need to
create many queue for allow different object running threads to
exchange messages between them in asyncronous mode. The message_queue

I think you are in wrong NG. IMO comp.programming.threads or a NG
related to your OS might be better. Therefore, rest of the answer is
from my own experience with threads (which is very small)
function is the best solution since allow to post a message into
another queue simply using the identification string. Currently, in my
implementation, each object create a message_queue identified with the
name of the object itself. Then create a thread remaining in wait for
new message. This allow objects to exchange messages using only the
name of the destination object. Very easy and very efficient.
"Unfortunately" I read in some post that this message_queue function is
made of interprocess communication and is not correct to use for
interthread communication. However what is the alternative?

What I am doing doesn't involve threads, but it requires IPC. We did the
measurements, and the IPC using message queues is very fast. Sending and
receiving big messages (20k-100k bytes) is almost instantly on our
target system (2-10 us delay).

I can only advise you to measure and see if it suits your needs.
And investigate if there are better methods :)
 
M

Miles Bader

Max said:
"Unfortunately" I read in some post that this message_queue function is
made of interprocess communication and is not correct to use for
interthread communication. However what is the alternative?

For inter-thread communication, you can simply use normal
data-structures (including those from boost), using
mutexes/condition_variables for synchronization as needed.
[If you're already doing thread programming, it should be pretty
straight-forward I'd think...]

-Miles
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top