Qt 4.8
|
The QFutureSynchronizer class is a convenience class that simplifies QFuture synchronization. More...
#include <qfuturesynchronizer.h>
Public Functions | |
void | addFuture (const QFuture< T > &future) |
Adds future to the list of managed futures. More... | |
bool | cancelOnWait () const |
Returns true if the cancel-on-wait feature is enabled; otherwise returns false. More... | |
void | clearFutures () |
Removes all managed futures from this QFutureSynchronizer. More... | |
QList< QFuture< T > > | futures () const |
Returns a list of all managed futures. More... | |
QFutureSynchronizer () | |
Constructs a QFutureSynchronizer. More... | |
QFutureSynchronizer (const QFuture< T > &future) | |
Constructs a QFutureSynchronizer and begins watching future by calling addFuture(). More... | |
void | setCancelOnWait (bool enabled) |
Enables or disables the cancel-on-wait feature based on the enabled argument. More... | |
void | setFuture (const QFuture< T > &future) |
Sets future to be the only future managed by this QFutureSynchronizer. More... | |
void | waitForFinished () |
Waits for all futures to finish. More... | |
~QFutureSynchronizer () | |
Calls waitForFinished() function to ensure that all futures have finished before destroying this QFutureSynchronizer. More... | |
Protected Variables | |
bool | m_cancelOnWait |
QList< QFuture< T > > | m_futures |
The QFutureSynchronizer class is a convenience class that simplifies QFuture synchronization.
QFutureSynchronizer is a template class that simplifies synchronization of one or more QFuture objects. Futures are added using the addFuture() or setFuture() functions. The futures() function returns a list of futures. Use clearFutures() to remove all futures from the QFutureSynchronizer.
The waitForFinished() function waits for all futures to finish. The destructor of QFutureSynchronizer calls waitForFinished(), providing an easy way to ensure that all futures have finished before returning from a function:
The behavior of waitForFinished() can be changed using the setCancelOnWait() function. Calling setCancelOnWait(true) will cause waitForFinished() to cancel all futures before waiting for them to finish. You can query the status of the cancel-on-wait feature using the cancelOnWait() function.
Definition at line 55 of file qfuturesynchronizer.h.
|
inline |
|
inlineexplicit |
Constructs a QFutureSynchronizer and begins watching future by calling addFuture().
Definition at line 61 of file qfuturesynchronizer.h.
|
inline |
Calls waitForFinished() function to ensure that all futures have finished before destroying this QFutureSynchronizer.
Definition at line 64 of file qfuturesynchronizer.h.
|
inline |
Adds future to the list of managed futures.
Definition at line 73 of file qfuturesynchronizer.h.
Referenced by QFutureSynchronizer< T >::QFutureSynchronizer(), and QFutureSynchronizer< T >::setFuture().
|
inline |
Returns true if the cancel-on-wait feature is enabled; otherwise returns false.
If cancel-on-wait is enabled, the waitForFinished() function will cancel all futures before waiting for them to finish.
Definition at line 106 of file qfuturesynchronizer.h.
|
inline |
Removes all managed futures from this QFutureSynchronizer.
Definition at line 91 of file qfuturesynchronizer.h.
|
inline |
Returns a list of all managed futures.
Definition at line 96 of file qfuturesynchronizer.h.
|
inline |
Enables or disables the cancel-on-wait feature based on the enabled argument.
If enabled is true, the waitForFinished() function will cancel all futures before waiting for them to finish.
Definition at line 101 of file qfuturesynchronizer.h.
|
inline |
Sets future to be the only future managed by this QFutureSynchronizer.
This is a convenience function that calls waitForFinished(), then clearFutures(), and finally passes future to addFuture().
Definition at line 66 of file qfuturesynchronizer.h.
|
inline |
Waits for all futures to finish.
If cancelOnWait() returns true, each future is canceled before waiting for them to finish.
Definition at line 78 of file qfuturesynchronizer.h.
Referenced by QFutureSynchronizer< T >::setFuture(), and QFutureSynchronizer< T >::~QFutureSynchronizer().
|
protected |
Definition at line 113 of file qfuturesynchronizer.h.
Referenced by QFutureSynchronizer< T >::cancelOnWait(), QFutureSynchronizer< T >::setCancelOnWait(), and QFutureSynchronizer< T >::waitForFinished().
|
protected |
Definition at line 112 of file qfuturesynchronizer.h.
Referenced by QFutureSynchronizer< T >::addFuture(), QFutureSynchronizer< T >::clearFutures(), QFutureSynchronizer< T >::futures(), QFutureSynchronizer< T >::setFuture(), and QFutureSynchronizer< T >::waitForFinished().