I am writing a computer vision program and want to use multiple threads with event loops to process independant computation tasks at once.
So its got this structre:
Qt Code:
( Thread 1 ) ( Thread 2 ) __________ _________ ___> | Module A1 |-->| Module A2 |-->| Module A3 |----->| Thread 4 | | Camera |____| | OpenGL | | Grabber| | | GUI | ---------- ---->| Module B1 | -->| Module B2|---------------------> ----------- ( Thread 3 )To copy to clipboard, switch view to plain text mode
Thread 2 and 3 connect to the camera thread's signal newFrame(Image*) so they start processing their stuff independently.
Thread 2 and 3 are also synchronized in such a way, that they only start to process a new fram if both of them finished their previous computation, otherwise thread 3 would process the next frame while thread 2 does not have the result yet and they become out of sync.
Now the question! If all signals get queued, what happens if the threads take longer to process than the camera thread sends frames? Will they keep accumulating in the event queue and i will always lag behind the current frame? If the answer is yes, is there a way to dequeue or overwrite pending events with a more recent one?
Bookmarks