Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Inter-thread alternative to Boost message_queue

Reply
Thread Tools

Inter-thread alternative to Boost message_queue

 
 
Max
Guest
Posts: n/a
 
      07-29-2010

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

--

 
Reply With Quote
 
 
 
 
Vladimir Jovic
Guest
Posts: n/a
 
      07-29-2010
Max wrote:
> 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
 
Reply With Quote
 
 
 
 
Miles Bader
Guest
Posts: n/a
 
      07-29-2010
"Max" <> writes:
> "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

--
Politics, n. A strife of interests masquerading as a contest of
principles. The conduct of public affairs for private advantage.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Boost::any and boost::lambda with std::find_if Misiu C++ 3 01-31-2007 05:46 PM
#include <boost/shared_ptr.hpp> or #include "boost/shared_ptr.hpp"? Colin Caughie C++ 1 08-29-2006 02:19 PM
Problems mixing boost::lambda::bind and boost::shared_ptr.. Toby Bradshaw C++ 6 06-02-2006 04:12 PM
Any Boost Experts out there for Boost.Regex? Richard Latter C++ 2 05-17-2004 03:12 PM
Boost + Python C/API: Mixing python return types with boost return types Steve Knight Python 2 10-10-2003 10:11 AM



Advertisments