Qt Labs Forum » Qt Concurrent

precisely one of finished() or canceled() called?

(2 posts)

  1. smr99
    smr99
    Member

    Hi,

    The QtConcurrent library looks promising. I spent several hours perusing the code and now my head hurts :-)

    I'd like to know what guarantees are intended by the library. For example, it would be nice to guarantee that QFutureWatcher will emit precisely one of finished() or canceled() and never both. I can't see the code that would provide this guarantee, though. On the contrary, it looks to me that FutureResultBase will happily send a cancel() after finished().

    Posted: 1 year #
  2. Morten
    Morten
    Member

    Hi,
    Such guarantees is something we would like to provide. Currently it looks something like this:

    1. You'll always get excactly one finished(), and this will happen once all worker threads are done so it's safe to free resources that the threads were using.
    2. If you cancel a QFuture you'll get canceled() immediately and then a finished() when the worker threads have exited (it may take some time before the worker threads detect the cancel).
    3. You'll never get canceled() after finished().

    This way you can rely on always getting finished(), and you know that all threads are done at that point.

    Posted: 1 year #

RSS feed for this topic

Reply

You must log in to post.



© 2008 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners.