Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTConcurrent::map cancel not working

QTConcurrent::map cancel not working

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    weisseruebe
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • W Offline
        W Offline
        weisseruebe
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved