Execution policy (multithreading)

This commit is contained in:
Jakub Melka
2020-01-18 14:55:26 +01:00
parent db493db3cc
commit 1fd01c14fd
14 changed files with 266 additions and 34 deletions

View File

@ -17,6 +17,7 @@
#include "pdftextlayout.h"
#include "pdfutils.h"
#include "pdfexecutionpolicy.h"
#include <QPainter>
@ -456,7 +457,7 @@ void PDFTextLayout::performDoLayout(PDFReal angle)
};
auto range = PDFIntegerRange<size_t>(0, characterCount);
std::for_each(std::execution::parallel_policy(), range.begin(), range.end(), findNearestCharacters);
PDFExecutionPolicy::execute(PDFExecutionPolicy::Scope::Content, range.begin(), range.end(), findNearestCharacters);
// Step 3) - detect lines
PDFUnionFindAlgorithm<size_t> textLinesUF(characterCount);
@ -847,7 +848,7 @@ PDFFindResults PDFTextLayoutStorage::find(const QString& text, Qt::CaseSensitivi
};
auto range = PDFIntegerRange<size_t>(0, m_offsets.size());
std::for_each(std::execution::parallel_policy(), range.begin(), range.end(), findImpl);
PDFExecutionPolicy::execute(PDFExecutionPolicy::Scope::Page, range.begin(), range.end(), findImpl);
std::sort(results.begin(), results.end());
return results;
@ -876,7 +877,7 @@ PDFFindResults PDFTextLayoutStorage::find(const QRegularExpression& expression,
};
auto range = PDFIntegerRange<size_t>(0, m_offsets.size());
std::for_each(std::execution::parallel_policy(), range.begin(), range.end(), findImpl);
PDFExecutionPolicy::execute(PDFExecutionPolicy::Scope::Page, range.begin(), range.end(), findImpl);
std::sort(results.begin(), results.end());
return results;