Multiple Producers Single Consumer Queue

Posted by Talguy on Stack Overflow See other posts from Stack Overflow or by Talguy
Published on 2010-04-28T16:05:18Z Indexed on 2010/04/28 16:33 UTC
Read the original article Hit count: 222

Filed under:
|
|
|

I am new to multithreading and have designed a program that receives data from two microcontroller measuring various temperatures (Ambient and Water) and draws the data to the screen. Right now the program is singly threaded and its performance SUCKS A BIG ONE.

I get basic design approaches with multithreading but not well enough to create a thread to do a task but what I don't get is how to get threads to perform seperate task and place the data into a shared data pool. I figured that I need to make a queue that has one consumer and multiple producers (would like to use std::queue). I have seen some code on the gtkmm threading docs that show a single Con/Pro queue and they would lock the queue object produce data and signal the sleeping thread that it is finished then the producer would sleep. For what I need would I need to sleep a thread, would there be data conflicts if i didn't sleep any of the threads, and would sleeping a thread cause a data signifcant data delay (I need realtime data to be drawn 30 frames a sec)

How would I go about coding such a queue using the gtkmm/glibmm library.

© Stack Overflow or respective owner

Related posts about gtkmm

Related posts about multithreading