Qt 4.8
Namespaces | Classes | Enumerations | Functions
QtConcurrent Namespace Reference

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

Namespaces

 internal
 The QtConcurrent::internal namespace contains QtConcurrent implementation details.
 

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

Enumerations

enum  ReduceOption { UnorderedReduce = 0x1, OrderedReduce = 0x2, SequentialReduce = 0x4 }
 This enum specifies the order of which results from the map or filter function are passed to the reduce function. More...
 

Functions

void blockingFilter (Sequence &sequence, FilterFunction filterFunction)
 Calls filterFunction once for each item in sequence. More...
 
template<typename Sequence >
Sequence blockingFiltered (const Sequence &sequence, FilterFunction filterFunction)
 Calls filterFunction once for each item in sequence and returns a new Sequence of kept items. More...
 
template<typename Sequence >
Sequence 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. More...
 
template<typename T >
blockingFilteredReduced (const Sequence &sequence, FilterFunction filterFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions=UnorderedReduce|SequentialReduce)
 Calls filterFunction once for each item in sequence. More...
 
template<typename T >
blockingFilteredReduced (ConstIterator begin, ConstIterator end, FilterFunction filterFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions=UnorderedReduce|SequentialReduce)
 Calls filterFunction once for each item from begin to end. More...
 
void blockingMap (Sequence &sequence, MapFunction function)
 Calls function once for each item in sequence. More...
 
void blockingMap (Iterator begin, Iterator end, MapFunction function)
 Calls function once for each item from begin to end. More...
 
template<typename T >
blockingMapped (const Sequence &sequence, MapFunction function)
 Calls function once for each item in sequence and returns a Sequence containing the results. More...
 
template<typename T >
blockingMapped (ConstIterator begin, ConstIterator end, MapFunction function)
 Calls function once for each item from begin to end and returns a container with the results. More...
 
template<typename T >
blockingMappedReduced (const Sequence &sequence, MapFunction function, ReduceFunction function, QtConcurrent::ReduceOptions options=UnorderedReduce|SequentialReduce)
 
template<typename T >
blockingMappedReduced (ConstIterator begin, ConstIterator end, MapFunction function, ReduceFunction function, QtConcurrent::ReduceOptions options=UnorderedReduce|SequentialReduce)
 
QFuture< void > filter (Sequence &sequence, FilterFunction filterFunction)
 
template<typename T >
QFuture< T > filtered (const Sequence &sequence, FilterFunction filterFunction)
 
template<typename T >
QFuture< T > filtered (ConstIterator begin, ConstIterator end, FilterFunction filterFunction)
 
template<typename T >
QFuture< T > filteredReduced (const Sequence &sequence, FilterFunction filterFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions=UnorderedReduce|SequentialReduce)
 
template<typename T >
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)
 
template<typename T >
QFuture< T > mapped (const Sequence &sequence, MapFunction function)
 
template<typename T >
QFuture< T > mapped (ConstIterator begin, ConstIterator end, MapFunction function)
 
template<typename T >
QFuture< T > mappedReduced (const Sequence &sequence, MapFunction function, ReduceFunction function, QtConcurrent::ReduceOptions options=UnorderedReduce|SequentialReduce)
 
template<typename T >
QFuture< T > mappedReduced (ConstIterator begin, ConstIterator end, MapFunction function, ReduceFunction function, QtConcurrent::ReduceOptions options=UnorderedReduce|SequentialReduce)
 
template<typename T >
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.

Attention
Module: QtCore
Since
4.4

See the Concurrent Programming {Qt Concurrent} chapter in the threading documentation.

QtCore

Enumeration Type Documentation

◆ ReduceOption

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

  • UnorderedReduce Reduction is done in an arbitrary order.
  • OrderedReduce Reduction is done in the order of the original sequence.
  • SequentialReduce Reduction 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.)
Enumerator
UnorderedReduce 
OrderedReduce 
SequentialReduce 

Definition at line 91 of file qtconcurrentreducekernel.h.

Function Documentation

◆ blockingFilter()

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.

◆ blockingFiltered() [1/2]

template<typename Sequence >
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()

◆ blockingFiltered() [2/2]

template<typename Sequence >
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()

◆ blockingFilteredReduced() [1/2]

template<typename T >
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()

◆ blockingFilteredReduced() [2/2]

template<typename T >
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()

◆ blockingMap() [1/2]

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

◆ blockingMap() [2/2]

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

◆ blockingMapped() [1/2]

template<typename T >
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()

◆ blockingMapped() [2/2]

template<typename T >
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()

◆ blockingMappedReduced() [1/2]

template<typename T >
T QtConcurrent::blockingMappedReduced ( const Sequence &  sequence,
MapFunction  function,
ReduceFunction  function,
QtConcurrent::ReduceOptions  options = UnorderedReduce|SequentialReduce 
)

◆ blockingMappedReduced() [2/2]

template<typename T >
T QtConcurrent::blockingMappedReduced ( ConstIterator  begin,
ConstIterator  end,
MapFunction  function,
ReduceFunction  function,
QtConcurrent::ReduceOptions  options = UnorderedReduce|SequentialReduce 
)

◆ filter()

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

◆ filtered() [1/2]

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

◆ filtered() [2/2]

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

◆ filteredReduced() [1/2]

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

◆ filteredReduced() [2/2]

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

◆ map() [1/2]

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

◆ map() [2/2]

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

◆ mapped() [1/2]

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

◆ mapped() [2/2]

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

◆ mappedReduced() [1/2]

template<typename T >
QFuture<T> QtConcurrent::mappedReduced ( const Sequence &  sequence,
MapFunction  function,
ReduceFunction  function,
QtConcurrent::ReduceOptions  options = UnorderedReduce|SequentialReduce 
)

◆ mappedReduced() [2/2]

template<typename T >
QFuture<T> QtConcurrent::mappedReduced ( ConstIterator  begin,
ConstIterator  end,
MapFunction  function,
ReduceFunction  function,
QtConcurrent::ReduceOptions  options = UnorderedReduce|SequentialReduce 
)

◆ run()

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