QTConcurrent::map cancel not working



  • Hi together,

    I'm processing multiple images with QtConcurrent::map

    I'm starting the processing with
    @
    future = QtConcurrent::map(images->begin(), images->end(), wrapper);
    watcher.setFuture(future);
    @

    and I'd like to cancel the processing by calling
    @
    watcher.cancel();
    @

    @
    watcher.isCanceled();
    @

    becomes true, but the threads are continuing and even new threads are started.

    I can't find any documentation about the canceling process. Are the running threads finished and no new threads started? Are running threads terminated? Is there a flag I missed that I have to check by myself?

    A single thread runs approx. 30 seconds.

    Regards
    Andreas


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    From the doc, not all futures can be cancelled (run cannot, but mapreduce can) Might also be the case for the map function.

    isCanceled doesn't mean ended, you have to use waitForFinished if you want synchronous cancelation.

    Hope it helps



  • Hi, glad to see you here!

    I couldn't find a reliable statement about the "cancelability" of map, but since mapreduce can be cancelled, I hoped that map can be, too.
    I understand that "run" can't be cancelled, because the thread would have to be terminated without being able to clean up behind.
    I would expect that no new threads will be created after canceling a map / mapreduce, but in my case, it continues until the whole sequence is finished...
    I'll have to try with a smaller example.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.