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  · 

QtConcurrent Namespace

The QtConcurrent namespace provides high-level APIs that make it possible to write multi-threaded programs without using low-level threading primitives. More...

 #include <QtCore>

This namespace was introduced in Qt 4.4.

Classes

class Exception
class UnhandledException

Types

enum ReduceOption { UnorderedReduce, OrderedReduce, SequentialReduce }
flags ReduceOptions

Functions

void blockingFilter ( Sequence & sequence, FilterFunction filterFunction )
Sequence blockingFiltered ( const Sequence & sequence, FilterFunction filterFunction )
Sequence blockingFiltered ( ConstIterator begin, ConstIterator end, FilterFunction filterFunction )
T blockingFilteredReduced ( const Sequence & sequence, FilterFunction filterFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce )
T blockingFilteredReduced ( ConstIterator begin, ConstIterator end, FilterFunction filterFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce )
void blockingMap ( Sequence & sequence, MapFunction function )
void blockingMap ( Iterator begin, Iterator end, MapFunction function )
T blockingMapped ( const Sequence & sequence, MapFunction function )
T blockingMapped ( ConstIterator begin, ConstIterator end, MapFunction function )
T blockingMappedReduced ( const Sequence & sequence, MapFunction mapFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce )
T blockingMappedReduced ( ConstIterator begin, ConstIterator end, MapFunction mapFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce )
QFuture<void> filter ( Sequence & sequence, FilterFunction filterFunction )
QFuture<T> filtered ( const Sequence & sequence, FilterFunction filterFunction )
QFuture<T> filtered ( ConstIterator begin, ConstIterator end, FilterFunction filterFunction )
QFuture<T> filteredReduced ( const Sequence & sequence, FilterFunction filterFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce )
QFuture<T> filteredReduced ( ConstIterator begin, ConstIterator end, FilterFunction filterFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce )
QFuture<void> map ( Sequence & sequence, MapFunction function )
QFuture<void> map ( Iterator begin, Iterator end, MapFunction function )
QFuture<T> mapped ( const Sequence & sequence, MapFunction function )
QFuture<T> mapped ( ConstIterator begin, ConstIterator end, MapFunction function )
QFuture<T> mappedReduced ( const Sequence & sequence, MapFunction mapFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce )
QFuture<T> mappedReduced ( ConstIterator begin, ConstIterator end, MapFunction mapFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce )
QFuture<T> run ( Function function, ... )

Detailed Description

The QtConcurrent namespace provides high-level APIs that make it possible to write multi-threaded programs without using low-level threading primitives.

See the Qt Concurrent chapter in the threading documentation.

Classes

class Exception

The Exception class provides a base class for exceptions that can transferred across threads. More...

class UnhandledException

The UnhandledException class represents an unhandled exception in a worker thread. More...

Type Documentation

enum QtConcurrent::ReduceOption
flags QtConcurrent::ReduceOptions

This enum specifies the order of which results from the map or filter function are passed to the reduce function.

ConstantValueDescription
QtConcurrent::UnorderedReduce0x1Reduction is done in an arbitrary order.
QtConcurrent::OrderedReduce0x2Reduction is done in the order of the original sequence.
QtConcurrent::SequentialReduce0x4Reduction is done sequentially: only one thread will enter the reduce function at a time. (Parallel reduction might be supported in a future version of Qt Concurrent.)

The ReduceOptions type is a typedef for QFlags<ReduceOption>. It stores an OR combination of ReduceOption values.

Function Documentation

void QtConcurrent::blockingFilter ( Sequence & sequence, FilterFunction filterFunction )

Calls filterFunction once for each item in sequence. If filterFunction returns true, the item is kept in sequence; otherwise, the item is removed from sequence.

Note: This function will block until all items in the sequence have been processed.

Sequence QtConcurrent::blockingFiltered ( const Sequence & sequence, FilterFunction filterFunction )

Calls filterFunction once for each item in sequence and returns a new Sequence of kept items. If filterFunction returns true, a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence.

Note: This function will block until all items in the sequence have been processed.

See also filtered().

Sequence QtConcurrent::blockingFiltered ( ConstIterator begin, ConstIterator end, FilterFunction filterFunction )

Calls filterFunction once for each item from begin to end and returns a new Sequence of kept items. If filterFunction returns true, a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence.

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also filtered().

T QtConcurrent::blockingFilteredReduced ( const Sequence & sequence, FilterFunction filterFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce )

Calls filterFunction once for each item in sequence. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, reduceFunction is called in the order of the original sequence.

Note: This function will block until all items in the sequence have been processed.

See also filteredReduced().

T QtConcurrent::blockingFilteredReduced ( ConstIterator begin, ConstIterator end, FilterFunction filterFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce )

Calls filterFunction once for each item from begin to end. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, the reduceFunction is called in the order of the original sequence.

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also filteredReduced().

void QtConcurrent::blockingMap ( Sequence & sequence, MapFunction function )

Calls function once for each item in sequence. The function is passed a reference to the item, so that any modifications done to the item will appear in sequence.

Note: This function will block until all items in the sequence have been processed.

See also map().

void QtConcurrent::blockingMap ( Iterator begin, Iterator end, MapFunction function )

Calls function once for each item from begin to end. The function is passed a reference to the item, so that any modifications done to the item will appear in the sequence which the iterators belong to.

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also map().

T QtConcurrent::blockingMapped ( const Sequence & sequence, MapFunction function )

Calls function once for each item in sequence and returns a Sequence containing the results. The type of the results will match the type returned my the MapFunction.

Note: This function will block until all items in the sequence have been processed.

See also mapped().

T QtConcurrent::blockingMapped ( ConstIterator begin, ConstIterator end, MapFunction function )

Calls function once for each item from begin to end and returns a container with the results. Specify the type of container as the a template argument, like this:

 QList<int> ints = QtConcurrent::blockingMapped<QList<int> >(beginIterator, endIterator, fn);

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also mapped().

T QtConcurrent::blockingMappedReduced ( const Sequence & sequence, MapFunction mapFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce )

Calls mapFunction once for each item in sequence. The return value of each mapFunction is passed to reduceFunction.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is determined by reduceOptions.

Note: This function will block until all items in the sequence have been processed.

See also mapped().

T QtConcurrent::blockingMappedReduced ( ConstIterator begin, ConstIterator end, MapFunction mapFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce )

Calls mapFunction once for each item from begin to end. The return value of each mapFunction is passed to reduceFunction.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined.

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also blockingMappedReduced().

QFuture<void> QtConcurrent::filter ( Sequence & sequence, FilterFunction filterFunction )

Calls filterFunction once for each item in sequence. If filterFunction returns true, the item is kept in sequence; otherwise, the item is removed from sequence.

QFuture<T> QtConcurrent::filtered ( const Sequence & sequence, FilterFunction filterFunction )

Calls filterFunction once for each item in sequence and returns a new Sequence of kept items. If filterFunction returns true, a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence.

QFuture<T> QtConcurrent::filtered ( ConstIterator begin, ConstIterator end, FilterFunction filterFunction )

Calls filterFunction once for each item from begin to end and returns a new Sequence of kept items. If filterFunction returns true, a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence.

QFuture<T> QtConcurrent::filteredReduced ( const Sequence & sequence, FilterFunction filterFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce )

Calls filterFunction once for each item in sequence. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, reduceFunction is called in the order of the original sequence.

QFuture<T> QtConcurrent::filteredReduced ( ConstIterator begin, ConstIterator end, FilterFunction filterFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce )

Calls filterFunction once for each item from begin to end. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, the reduceFunction is called in the order of the original sequence.

QFuture<void> QtConcurrent::map ( Sequence & sequence, MapFunction function )

Calls function once for each item in sequence. The function is passed a reference to the item, so that any modifications done to the item will appear in sequence.

QFuture<void> QtConcurrent::map ( Iterator begin, Iterator end, MapFunction function )

Calls function once for each item from begin to end. The function is passed a reference to the item, so that any modifications done to the item will appear in the sequence which the iterators belong to.

QFuture<T> QtConcurrent::mapped ( const Sequence & sequence, MapFunction function )

Calls function once for each item in sequence and returns a future with each mapped item as a result. You can use QFuture::const_iterator or QFutureIterator to iterate through the results.

QFuture<T> QtConcurrent::mapped ( ConstIterator begin, ConstIterator end, MapFunction function )

Calls function once for each item from begin to end and returns a future with each mapped item as a result. You can use QFuture::const_iterator or QFutureIterator to iterate through the results.

QFuture<T> QtConcurrent::mappedReduced ( const Sequence & sequence, MapFunction mapFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce )

Calls mapFunction once for each item in sequence. The return value of each mapFunction is passed to reduceFunction.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is determined by reduceOptions.

QFuture<T> QtConcurrent::mappedReduced ( ConstIterator begin, ConstIterator end, MapFunction mapFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce )

Calls mapFunction once for each item from begin to end. The return value of each mapFunction is passed to reduceFunction.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. By default, the order in which reduceFunction is called is undefined.

Note: QtConcurrent::OrderedReduce results in the ordered reduction.

QFuture<T> QtConcurrent::run ( Function function, ... )

Runs function in a separate thread. The thread is taken from the global QThreadPool. Note that the function may not run immediately; the function will only be run when a thread is available.

T is the same type as the return value of function. Non-void return values can be accessed via the QFuture::result() function.

Note that the QFuture returned by QtConcurrent::run() does not support canceling, pausing, or progress reporting. The QFuture returned can only be used to query for the running/finished status and the return value of the function.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Developer Network au hasard

Logo

Comment fermer une application

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

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