Results 1 to 2 of 2

Thread: QFuture waitForFinished() and result()

  1. #1
    Join Date
    Apr 2012
    Posts
    5
    Thanks
    1

    Default QFuture waitForFinished() and result()

    Hi all, I am wondering what the differences between QFuture methods waitForFinished and result exactly are. Do not both methods wait for results from computation in the different threads to finish? Thanks and regards.

  2. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFuture waitForFinished() and result()

    Basically yes.

    The difference is that waitForFinished() only tests for thread state (returns when no longer running) when result() checks also for internal result and returns when thread has finished or result is ready.

    Qt Code:
    1. // waitForFinished():
    2. while (d->state & Running)
    3. d->waitCondition.wait(&d->m_mutex);
    4.  
    5. // waitForResult():
    6. while ((d->state & Running) && d->internal_isResultReadyAt(waitIndex) == false)
    7. d->waitCondition.wait(&d->m_mutex);
    8. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QWaitCondition woken by QFuture
    By ibex in forum Qt Programming
    Replies: 3
    Last Post: 28th December 2011, 19:10
  2. QFutureWatcher finished without even starting a QFuture...
    By Zweistein in forum Qt Programming
    Replies: 0
    Last Post: 22nd September 2011, 14:30
  3. Appropriate QFuture use?
    By mgb_qt in forum Qt Programming
    Replies: 3
    Last Post: 22nd July 2010, 19:34
  4. QtConcurrent mappedReduced QFuture Core Dump
    By shawno in forum Qt Programming
    Replies: 0
    Last Post: 16th July 2010, 02:29
  5. Replies: 14
    Last Post: 8th September 2009, 11:01

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.