Boost logo

Boost Users :

Subject: [Boost-users] boost multithread deisign for large and fast data exchange
From: Jack Bryan (dtustudy68_at_[hidden])
Date: 2011-10-10 00:48:23


Hi,
I am doing C++ multithreaded coding on Linux.

Each thread hold some messagers, who need to talk (exchange message) to other messagers.

Each messager is not only a message pruducer but also a message consumer.

If a messager needs to talk to another messager and both of them are held by the same thread , that is intra-hread talk.

Otherwise, it is inter-thread talk.

A messager can generate multiple messages, each of which has a distinct message-receiver ID. Each messager needs to do some computing tasks in order to produce a message.

Only the messager with match ID can receive and consume the message.

All messagers work asynchronously and the message exchange (like a multicast) pairs are fixed and do not change in the whole process of the program.

In order to simulate the above message exchange, I want to associate a priority message queue with each thread such that

(1) Each messager in a priority queue is an element. Whenever a messager's computing task is done and its message is ready for sending out, it has the highest priority and it is poped out and saved in a map with the messager's receiver ID as key.

(2) Then, the messager is push backed to the queue again and wait for receiving messgae from its talk pairs and do the above step (1).

(3) each thread is associated with a queue like this. Sometimes, do inter-thread talk and some times do intra-thread talk.

My questions:

How to efficiently implement the above idea with boost data containers, thread, thread pool, boost algorithm or other boost components ?

Are there other better ways to simulate the talk ?

Any help, advice or idea is really appreciated.

Thanks

                                               



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net