I have a desktop application where certain calculations, when requested by the user, are performed in the background thread. Cancel button.
I know the “safe” or “right” ways to cancel signaling in the background job (using Qt signal / slot connections, mutex-wrapped buffers, which background tasks are polled for, etc.).
However, the simplest thing, it seems to me, is bool cancelledin my class the main thread, which is installed synchronously when the Cancel button is pressed and transferred const bool &cancelledto the background thread on which it polls.
Is there any realistic way this approach can have unpleasant consequences?
source
share