【发布时间】:2016-11-08 05:24:45
【问题描述】:
据我了解QtConcurrent::blockingMappedReduced 返回最终结果,而QtConcurrent::MappedReduced 返回一个QFuture 对象,但在本例中http://doc.qt.io/qt-5/qtconcurrent-wordcount-main-cpp.html 我看到这样的代码:
WordCount total = QtConcurrent::mappedReduced(files, countWords, reduce);
QtConcurrent::mappedReduced 函数也返回最终结果。我错过了什么吗?如果这是错误的,那么使用QtConcurrent::mappedReduced 返回的结果的正确方法是什么?在什么情况下我应该QtConcurrent::mappedReduced 而不是QtConcurrent::blockingMappedReduced?请指教。
【问题讨论】:
-
我猜示例代码使用the implicit conversion of QFuture to its underlying type 与调用
WordCount total = QtConcurrent::mappedReduced(files, countWords, reduce).result();相同
标签: c++ qt qtconcurrent