Inter-thread alternative to Boost message_queue

Discussion in 'C++' started by Max, Jul 29, 2010.

  1. Max

    Max Guest

    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

    --
     
    Max, Jul 29, 2010
    #1
    1. Advertising

  2. 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 :)
     
    Vladimir Jovic, Jul 29, 2010
    #2
    1. Advertising

  3. Max

    Miles Bader Guest

    "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.
     
    Miles Bader, Jul 29, 2010
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Cornell
    Replies:
    1
    Views:
    5,601
  2. Miroslaw Makowiecki

    boost.thread library and the thread is running

    Miroslaw Makowiecki, Aug 9, 2007, in forum: C++
    Replies:
    1
    Views:
    484
    Victor Bazarov
    Aug 9, 2007
  3. Christopher
    Replies:
    0
    Views:
    1,464
    Christopher
    Jun 8, 2011
  4. Caleb Clausen

    Inter-thread synchronization

    Caleb Clausen, Nov 7, 2006, in forum: Ruby
    Replies:
    4
    Views:
    219
    David Vallner
    Nov 8, 2006
  5. brad
    Replies:
    2
    Views:
    538
    Ian Cass
    Feb 16, 2004
Loading...

Share This Page