Hello everyone!
Thanks for all the help I already got. And excuse my poor understanding of
of multithreading.
I would like to implement a "multiple producer single consumer" pattern.
My current solution is working with signals, which, I think is not very
efficient. And also it doesn't work properly with the code I have, (see end of
this mail). But besides that problem I have a generic question.
If I worked with buffers and mutex, there are two choices, it seems:
1. Use one buffer, at the cost of deletion from the middle, when one producer
terminates (so consumer won't communicate with a dead thread).
2. Have a buffer per producer, but also have a synchronisation per buffer and
the consumer must look in several buffers, plus I don't know, how many
producers there will be.
This all should lead to a user interface, with different input-methods. So
what would you suggest? It must be speedy and very CPU friendly.
Thanks in advance for consideration. I'd also be happy for some suggested
reading. Only one thing: printed books or documents in non-plain-text form
besides .doc, .pdf and .ps aren't of any use to me, for I'm blind and using
Linux text based environment.
Kindest regards (For code, see below)
Julien
*** CODE SNIPPET ***
boost::mutex my_mtx; // the Mutex for passing on events/chars
// assumptions:
// the following variables are passed to the Input object as a reference
// int& its_q_size;
// condition& its_in_condition;
// condition& its_out_condition;
// boost::signals2::signal