C++ QT并发阻塞MappedReduced v.s MappedReduced

C++ QT并发阻塞MappedReduced v.s MappedReduced,c++,qt,qtconcurrent,C++,Qt,Qtconcurrent,根据我的理解,QtConcurrent::blockingMappedReduced返回最终结果,而QtConcurrent::MappedReduced返回一个QFuture对象,但在本例中,我看到了如下代码: WordCount total = QtConcurrent::mappedReduced(files, countWords, reduce); QtConcurrent::mappedReduced函数还返回最终结果。我错过什么了吗?如果这是错误的,那么使用QtConcurren

根据我的理解,
QtConcurrent::blockingMappedReduced
返回最终结果,而
QtConcurrent::MappedReduced
返回一个
QFuture
对象,但在本例中,我看到了如下代码:

WordCount total = QtConcurrent::mappedReduced(files, countWords, reduce);

QtConcurrent::mappedReduced
函数还返回最终结果。我错过什么了吗?如果这是错误的,那么使用
QtConcurrent::mappedReduced
返回的结果的正确方法是什么?在什么条件下我应该
QtConcurrent::mappedReduced
而不是
QtConcurrent::blockingMappedReduced
?请告知。

在示例中,
QFuture
对象使用QFuture对象直接返回到
WordCount
,该对象阻塞并等待结果变为可用

typedef QMap<QString, int> WordCount;
WordCount total = mappedReduced(files, countWords, reduce);
如果要与QFuture对象交互(暂停、恢复、检查结果是否就绪),则可以通过调用
mappedReduced
而不使用阻塞函数来异步处理它

QFuture future=mappedReduced(文件、countWords、reduce);

qDebug()我猜示例代码使用的方法与调用
WordCount total=QtConcurrent::mappedReduced(files,countWords,reduce).result()相同WordCount total = blockingMappedReduced(files, countWords, reduce);

QFuture<WordCount> future = mappedReduced(files, countWords, reduce);
WordCount total = future.result();
QFuture<WordCount> future = mappedReduced(files, countWords, reduce);
qDebug() << future.isResultReadyAt(0); // returns false