Answer the question
In order to leave comments, you need to log in
How to implement the architecture of a multi-threaded application for drawing a graph?
Good time, dear developers!
I came across a problem and something tells me that there must be some pattern here, because the problem is quite typical.
Essence:
There is a data source that generates a stream at a speed of 5 Gb / s (USB 3.0).
The project is written in C++ using STL, QWT, QT libraries.
You need to process this stream in the application in a certain way (ie, perform some not very heavy math) or write the stream to disk as a binary file.
I have no experience in solving such problems, so I solved it as I imagined.
After some thought, I decided to do this:
There are 3 threads and a shared non-blocking queue
Answer the question
In order to leave comments, you need to log in
Your solution is bad right off the bat only because the second stream "outputs" the data on the chart. Pulling gui from a side stream is a bad idea, there will be strange and elusive bugs with high chances. And so everything is OK, in my opinion.
Moment number 1. Qt requires that the GUI only live in the main thread. And if the math is simple, and the USB speed is not critical, then let the math lie in the same stream. as reading from USB.
Moment number 2. An infinitely spinning cycle is the last measure. In Qt you have signals, so use them.
USb receives data and pushes the signal. it is picked up by mathematics and, after processing, pushes the signal. It is received by the GUI and displays the data.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question