I got sensor data of various types that needs to be processed at different stages. From what I have read around, the most efficent way is to split the tasks into threads. Each puts the processed data into the entry queue of the next thread. So basically, a pipeline.
The data can be quite large (a few Mbs) so it needs to be copied out of the sensor buffer and then passed along to the threads that will modify it and pass it along.
I am interested in understanding the best way to do the passing. I read that, if I do message posting between threads, I could allocate the data and pass the pointer to the other threads so the receiving thread can take care of de-allocating it. I am not quite sure, how this would work for streaming data, that is to make sure that the threads process the messages in order (I guess I could add a time check?). Also what data structure should I use for such an implementation? I presume I would need to use locks anyway?
Would it be more efficient to have synchronised queues?
Let me know if other solutions are better. The computations need to happen in real-time so I need this to be really efficient. If anyone has links to good examples of data being passed through a pipeline of threads I would be very interested in looking at it.
Caveats: No boost or other libraries. Using Pthreads. I need to keep the implementation as close to the standard libraries as possible. This will eventually be used on various platforms (which I don't know yet).