Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QFutureSynchronizer Class Reference

The QFutureSynchronizer class is a convenience class that simplifies QFuture synchronization. More...

 #include <QFutureSynchronizer>

This class was introduced in Qt 4.4.

Public Functions

QFutureSynchronizer ()
QFutureSynchronizer ( const QFuture<T> & future )
~QFutureSynchronizer ()
void addFuture ( const QFuture<T> & future )
bool cancelOnWait () const
void clearFutures ()
QList<QFuture<T> > futures () const
void setCancelOnWait ( bool enabled )
void setFuture ( const QFuture<T> & future )
void waitForFinished ()

Detailed Description

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:

 void someFunction()
 {
     QFutureSynchronizer<void> synchronizer;

     ...

     synchronizer.addFuture(QtConcurrent::run(anotherFunction));
     synchronizer.addFuture(QtConcurrent::map(list, mapFunction));

     return; // QFutureSynchronizer waits for all futures to finish
 }

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.

See also QFuture, QFutureWatcher, and Qt Concurrent.

Member Function Documentation

QFutureSynchronizer::QFutureSynchronizer ()

Constructs a QFutureSynchronizer.

QFutureSynchronizer::QFutureSynchronizer ( const QFuture<T> & future )

Constructs a QFutureSynchronizer and begins watching future by calling addFuture().

See also addFuture().

QFutureSynchronizer::~QFutureSynchronizer ()

Calls waitForFinished() function to ensure that all futures have finished before destroying this QFutureSynchronizer.

See also waitForFinished().

void QFutureSynchronizer::addFuture ( const QFuture<T> & future )

Adds future to the list of managed futures.

See also futures().

bool QFutureSynchronizer::cancelOnWait () const

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.

See also setCancelOnWait() and waitForFinished().

void QFutureSynchronizer::clearFutures ()

Removes all managed futures from this QFutureSynchronizer.

See also addFuture() and setFuture().

QList<QFuture<T> > QFutureSynchronizer::futures () const

Returns a list of all managed futures.

See also addFuture() and setFuture().

void QFutureSynchronizer::setCancelOnWait ( bool enabled )

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.

See also cancelOnWait() and waitForFinished().

void QFutureSynchronizer::setFuture ( const QFuture<T> & future )

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().

See also addFuture(), waitForFinished(), and clearFutures().

void QFutureSynchronizer::waitForFinished ()

Waits for all futures to finish. If cancelOnWait() returns true, each future is canceled before waiting for them to finish.

See also cancelOnWait() and setCancelOnWait().

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.8
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web