Is my multithreading approach correct?
Solved
General and Desktop
-
I wrote a simple GUI application for the rendering of an algorithm. Since I need a responsive and smooth user application, I divided the main GUI into three classes:
- a computing thread, which simply does computations and emits new data as soon as they are computed via a signal
- a processing class, which simply catches the computing thread's signals, processes them, and every n milliseconds emits a signal with the processed data to the GUI class; the signal is emitted only every n milliseconds, in order not to choke the GUI with thousands of signals
- a GUI class, which catches signals from the processing class and update the GUI accordingly
Now, everything seems to run smoothly. My first approach was with a computing thread and the GUI class, but I had to also process data in the computing thread, slowing down the execution.
Is my approach correct?
-
Hi
Its sounds like the classic
worker - processing - display design with the twist of
caching signals in processing.In my opinion is a very good design. :)