I use QThreadPool and QRunnable . How to complete the work of QRunnable , if that of the queue has already moved to the running state?
QThreadPool has a method that allows you to remove execution objects from the pool, but only those that are still in the queue.
In theory, in the successor of QRunnable a certain flag is needed (like QThread::requestInterruption() ), which could be switched from the outside, and the execution object would look from time to time to the value of this flag. Accordingly, if it is time to round out, then he would complete his work.
However, in this case, you need to store a list of QRunnable objects in order to be able to set the flag, and eventually have the probability of the program QThreadPool if QThreadPool any of them in advance. I don’t want to refuse QRunnable::autoDelete() == true .
Is it possible to somehow solve this problem without leaving QThread and changing QRunnable::autoDelete() == true , since the convenience of using QThreadPool ?