Mesh: replace QtConcurrent::run with std::async
This commit is contained in:
@@ -369,7 +369,7 @@ void MeshFastBuilder::Finish()
|
||||
}
|
||||
|
||||
// std::sort(verts.begin(), verts.end());
|
||||
int threads = QThread::idealThreadCount();
|
||||
int threads = int(std::thread::hardware_concurrency());
|
||||
MeshCore::parallel_sort(verts.begin(), verts.end(), std::less<>(), threads);
|
||||
|
||||
QVector<FacetIndex> indices(ulCtPts);
|
||||
|
||||
@@ -991,7 +991,7 @@ void MeshKernel::RebuildNeighbours(FacetIndex index)
|
||||
|
||||
// sort the edges
|
||||
// std::sort(edges.begin(), edges.end(), Edge_Less());
|
||||
int threads = QThread::idealThreadCount();
|
||||
int threads = int(std::thread::hardware_concurrency());
|
||||
MeshCore::parallel_sort(edges.begin(), edges.end(), Edge_Less(), threads);
|
||||
|
||||
PointIndex p0 = POINT_INDEX_MAX, p1 = POINT_INDEX_MAX;
|
||||
|
||||
@@ -23,9 +23,8 @@
|
||||
#ifndef MESH_FUNCTIONAL_H
|
||||
#define MESH_FUNCTIONAL_H
|
||||
|
||||
#include <QFuture>
|
||||
#include <QtConcurrentRun>
|
||||
#include <algorithm>
|
||||
#include <future>
|
||||
|
||||
|
||||
namespace MeshCore
|
||||
@@ -39,18 +38,25 @@ static void parallel_sort(Iter begin, Iter end, Pred comp, int threads)
|
||||
else {
|
||||
Iter mid = begin + (end - begin) / 2;
|
||||
if (threads == 2) {
|
||||
QFuture<void> future =
|
||||
QtConcurrent::run(parallel_sort<Iter, Pred>, begin, mid, comp, threads / 2);
|
||||
auto future = std::async(parallel_sort<Iter, Pred>, begin, mid, comp, threads / 2);
|
||||
std::sort(mid, end, comp);
|
||||
future.waitForFinished();
|
||||
future.wait();
|
||||
}
|
||||
else {
|
||||
QFuture<void> a =
|
||||
QtConcurrent::run(parallel_sort<Iter, Pred>, begin, mid, comp, threads / 2);
|
||||
QFuture<void> b =
|
||||
QtConcurrent::run(parallel_sort<Iter, Pred>, mid, end, comp, threads / 2);
|
||||
a.waitForFinished();
|
||||
b.waitForFinished();
|
||||
auto a = std::async(std::launch::async,
|
||||
parallel_sort<Iter, Pred>,
|
||||
begin,
|
||||
mid,
|
||||
comp,
|
||||
threads / 2);
|
||||
auto b = std::async(std::launch::async,
|
||||
parallel_sort<Iter, Pred>,
|
||||
mid,
|
||||
end,
|
||||
comp,
|
||||
threads / 2);
|
||||
a.wait();
|
||||
b.wait();
|
||||
}
|
||||
std::inplace_merge(begin, mid, end, comp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user