Describe the bug
The dispatcher_middleman class is used to communicate between the second thread (that calls commands) and the main GUI thread. Currently, if the second thread calls any update command twice before the main thread is able to run handle_signal, then the data from the first update call is overwritten and never used.
To Reproduce
Steps to reproduce the behavior:
Make the unit tests
Run ./dist/appanvil_test
Examine the results of DispatcherMiddlemanTest.UPDATE_PROFILES_PROCESSES_INTERLOCKING
Expected behavior
Whenever an update method is called from a second thread of dispatcher_middleman, we expect that
whenever the main thread runs handle_signal, it is able to see the data that was saved in the update method.
Instead of using two variables to store data, we should use a blocking_queue to store the data from each update call. Then,
in the handle_signal method, we can pop the data from the queue and use this. We may be even able to remove the mutex from dispatcher_middleman using this approach.
Additional context
This bug is unlikely to ever present itself in a practical situation, but eventually be fixed. This can happen if the Main thread sends two commands, then waits for a while before finally running handle_signal. With the current state of the code, we rarely send two commands to console_thread in quick succession like this.
Describe the bug The
dispatcher_middleman
class is used to communicate between the second thread (that calls commands) and the main GUI thread. Currently, if the second thread calls anyupdate
command twice before the main thread is able to runhandle_signal
, then the data from the firstupdate
call is overwritten and never used.To Reproduce Steps to reproduce the behavior:
./dist/appanvil_test
DispatcherMiddlemanTest.UPDATE_PROFILES_PROCESSES_INTERLOCKING
Expected behavior Whenever an
update
method is called from a second thread ofdispatcher_middleman
, we expect that whenever the main thread runshandle_signal
, it is able to see the data that was saved in theupdate
method.Instead of using two variables to store data, we should use a
blocking_queue
to store the data from eachupdate
call. Then, in thehandle_signal
method, we can pop the data from the queue and use this. We may be even able to remove the mutex fromdispatcher_middleman
using this approach.Additional context This bug is unlikely to ever present itself in a practical situation, but eventually be fixed. This can happen if the Main thread sends two commands, then waits for a while before finally running
handle_signal
. With the current state of the code, we rarely send two commands toconsole_thread
in quick succession like this.