public final class QtConcurrent extends Object
High-level APIs that make it possible to write multi-threaded programs without using low-level threading primitives
Java wrapper for Qt class QtConcurrent
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
QtConcurrent.FilteredFunctor<T>
An implementation of this interface is given to one of QtConcurrent's filtered() methods.static interface
QtConcurrent.MapFunctor<T>
An implemetation of this interface is given one to QtConcurrent's map() methods.static interface
QtConcurrent.MappedFunctor<U,T>
Implement this interface to perform a mapped operation.static class
QtConcurrent.MedianDouble
Java wrapper for Qt class QtConcurrent::MedianDoublestatic interface
QtConcurrent.ReducedFunctor<U,T>
Implement this interface in order to perform a reduce operation.static class
QtConcurrent.ReduceOption
Java wrapper for Qt enum QtConcurrent::ReduceOptionstatic class
QtConcurrent.ReduceOptions
QFlags type for enumQtConcurrent.ReduceOption
static class
QtConcurrent.ThreadFunctionResult
Java wrapper for Qt enum QtConcurrent::ThreadFunctionResult -
Method Summary
Modifier and Type Method Description static <T> void
blockingFilter(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor)
Calls filterFunction once for each item in sequence.static <T> List<T>
blockingFiltered(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor)
Calls filterFunctor's filtered() method once for each item in sequence and returns a new Sequence of kept items.static <U, T> U
blockingFilteredReduced(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor, QtConcurrent.ReducedFunctor<U,T> reducedFunctor)
This is an overloaded method provided for convenience.static <U, T> U
blockingFilteredReduced(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor, QtConcurrent.ReducedFunctor<U,T> reducedFunctor, QtConcurrent.ReduceOption... options)
Calls filterFunction once for each item in sequence.static <U, T> U
blockingFilteredReduced(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor, QtConcurrent.ReducedFunctor<U,T> reducedFunctor, QtConcurrent.ReduceOptions options)
Calls filterFunction once for each item in sequence.static <T> void
blockingMap(Collection<T> sequence, QtConcurrent.MapFunctor<T> functor)
Calls function once for each item in sequence.static <U, T> List<U>
blockingMapped(Collection<T> sequence, QtConcurrent.MappedFunctor<U,T> functor)
Calls function once for each item in sequence and returns a future with each mapped item as a result.static <U, V, T> U
blockingMappedReduced(Collection<T> sequence, QtConcurrent.MappedFunctor<V,T> functor, QtConcurrent.ReducedFunctor<U,V> reducedFunctor)
This is an overloaded method provided for convenience.static <U, V, T> U
blockingMappedReduced(Collection<T> sequence, QtConcurrent.MappedFunctor<V,T> functor, QtConcurrent.ReducedFunctor<U,V> reducedFunctor, QtConcurrent.ReduceOption... options)
Calls mapFunction once for each item in sequence.static <U, V, T> U
blockingMappedReduced(Collection<T> sequence, QtConcurrent.MappedFunctor<V,T> functor, QtConcurrent.ReducedFunctor<U,V> reducedFunctor, QtConcurrent.ReduceOptions options)
Calls mapFunction once for each item in sequence.static <T> QFuture<T>
filtered(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor)
Calls filterFunctor's filtered() method once for each item in sequence and returns a new Sequence of kept items.static <U, T> QFuture<U>
filteredReduced(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor, QtConcurrent.ReducedFunctor<U,T> reducedFunctor)
This is an overloaded method provided for convenience.static <U, T> QFuture<U>
filteredReduced(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor, QtConcurrent.ReducedFunctor<U,T> reducedFunctor, QtConcurrent.ReduceOption... options)
Calls filterFunction once for each item in sequence.static <U, T> QFuture<U>
filteredReduced(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor, QtConcurrent.ReducedFunctor<U,T> reducedFunctor, QtConcurrent.ReduceOptions options)
Calls filterFunction once for each item in sequence.static <T> QFutureVoid
map(Collection<T> sequence, QtConcurrent.MapFunctor<T> functor)
Calls function once for each item in sequence.static <U, T> QFuture<U>
mapped(Collection<T> sequence, QtConcurrent.MappedFunctor<U,T> functor)
Calls function once for each item in sequence and returns a future with each mapped item as a result.static <U, V, T> QFuture<U>
mappedReduced(Collection<T> sequence, QtConcurrent.MappedFunctor<V,T> functor, QtConcurrent.ReducedFunctor<U,V> reducedFunctor)
This is an overloaded method provided for convenience.static <U, V, T> QFuture<U>
mappedReduced(Collection<T> sequence, QtConcurrent.MappedFunctor<V,T> functor, QtConcurrent.ReducedFunctor<U,V> reducedFunctor, QtConcurrent.ReduceOption... options)
This is an overloaded method provided for convenience.static <U, V, T> QFuture<U>
mappedReduced(Collection<T> sequence, QtConcurrent.MappedFunctor<V,T> functor, QtConcurrent.ReducedFunctor<U,V> reducedFunctor, QtConcurrent.ReduceOptions options)
Calls mapFunction once for each item in sequence.static QFutureVoid
run(QThreadPool threadPool, Runnable runnable)
Executes the RunnableVoid
using the QtConcurrent framework.static <T> QFuture<T>
run(QThreadPool threadPool, Callable<T> callable)
Executes the Callablecallable
through the QtConcurrent framework.static QFutureVoid
run(Runnable runnable)
Executes the RunnableVoid
using the QtConcurrent framework.static <T> QFuture<T>
run(Callable<T> callable)
Executes the Callablecallable
through the QtConcurrent framework.
-
Method Details
-
map
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. -
blockingMap
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. -
mapped
public static <U, T> QFuture<U> mapped(Collection<T> sequence, QtConcurrent.MappedFunctor<U,T> functor)Calls function once for each item in sequence and returns a future with each mapped item as a result. You can QFutureIterator to iterate through the results. -
blockingMapped
public static <U, T> List<U> blockingMapped(Collection<T> sequence, QtConcurrent.MappedFunctor<U,T> functor)Calls function once for each item in sequence and returns a future with each mapped item as a result. You can QFutureIterator to iterate through the results. -
mappedReduced
public static <U, V, T> QFuture<U> mappedReduced(Collection<T> sequence, QtConcurrent.MappedFunctor<V,T> functor, QtConcurrent.ReducedFunctor<U,V> reducedFunctor)This is an overloaded method provided for convenience.It is equivalent of mappedReduced(sequence, functor, reducedFunctor, ReduceOption.UnorderedReduce, ReduceOption.SequentialReduce)
-
mappedReduced
public static <U, V, T> QFuture<U> mappedReduced(Collection<T> sequence, QtConcurrent.MappedFunctor<V,T> functor, QtConcurrent.ReducedFunctor<U,V> reducedFunctor, QtConcurrent.ReduceOption... options)This is an overloaded method provided for convenience.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.
-
mappedReduced
public static <U, V, T> QFuture<U> mappedReduced(Collection<T> sequence, QtConcurrent.MappedFunctor<V,T> functor, QtConcurrent.ReducedFunctor<U,V> reducedFunctor, QtConcurrent.ReduceOptions options)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.
-
blockingMappedReduced
public static <U, V, T> U blockingMappedReduced(Collection<T> sequence, QtConcurrent.MappedFunctor<V,T> functor, QtConcurrent.ReducedFunctor<U,V> reducedFunctor)This is an overloaded method provided for convenience.It is equivalent of calling blockingMappedReduced(sequence, functor, reducedFunctor, ReduceOption.UnorderedReduce, ReduceOption.SequentialReduce)
-
blockingMappedReduced
public static <U, V, T> U blockingMappedReduced(Collection<T> sequence, QtConcurrent.MappedFunctor<V,T> functor, QtConcurrent.ReducedFunctor<U,V> reducedFunctor, QtConcurrent.ReduceOption... options)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.
-
blockingMappedReduced
public static <U, V, T> U blockingMappedReduced(Collection<T> sequence, QtConcurrent.MappedFunctor<V,T> functor, QtConcurrent.ReducedFunctor<U,V> reducedFunctor, QtConcurrent.ReduceOptions options)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.
-
filtered
public static <T> QFuture<T> filtered(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor)Calls filterFunctor's filtered() method 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. -
blockingFiltered
public static <T> List<T> blockingFiltered(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor)Calls filterFunctor's filtered() method 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. -
blockingFilter
public static <T> void blockingFilter(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor)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. -
filteredReduced
public static <U, T> QFuture<U> filteredReduced(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor, QtConcurrent.ReducedFunctor<U,T> reducedFunctor)This is an overloaded method provided for convenience. It is equivalent of calling filteredReduced(sequence, filteredFunctor, ReduceOption.UnorderedReduce, ReduceOption.Seq This is an overloaded method provided for convenience. It is equivalent of calling filteredReduced) -
filteredReduced
public static <U, T> QFuture<U> filteredReduced(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor, QtConcurrent.ReducedFunctor<U,T> reducedFunctor, QtConcurrent.ReduceOption... options)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.
-
filteredReduced
public static <U, T> QFuture<U> filteredReduced(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor, QtConcurrent.ReducedFunctor<U,T> reducedFunctor, QtConcurrent.ReduceOptions options)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.
-
blockingFilteredReduced
public static <U, T> U blockingFilteredReduced(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor, QtConcurrent.ReducedFunctor<U,T> reducedFunctor)This is an overloaded method provided for convenience. It is the equivalent of calling blockingFilteredReduced(sequence, filteredFunctor, reducedFunctor, ReduceOption.UnorderedReduce, ReduceOption.SequentialReduce) -
blockingFilteredReduced
public static <U, T> U blockingFilteredReduced(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor, QtConcurrent.ReducedFunctor<U,T> reducedFunctor, QtConcurrent.ReduceOption... options)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.
-
blockingFilteredReduced
public static <U, T> U blockingFilteredReduced(Collection<T> sequence, QtConcurrent.FilteredFunctor<T> filteredFunctor, QtConcurrent.ReducedFunctor<U,T> reducedFunctor, QtConcurrent.ReduceOptions options)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.
-
run
Executes the Callablecallable
through the QtConcurrent framework. The returned QFuture object's result will be the return value ofcallable
. -
run
Executes the Callablecallable
through the QtConcurrent framework. The thread is taken from the QThreadPool pool. The returned QFuture object's result will be the return value ofcallable
. -
run
Executes the RunnableVoid
using the QtConcurrent framework. -
run
Executes the RunnableVoid
using the QtConcurrent framework. The thread is taken from the QThreadPool pool.
-