From 391725240a8021aa2a36ed804e8e4fada4906eac Mon Sep 17 00:00:00 2001 From: Joergen Schartum Dokken Date: Mon, 18 May 2026 15:11:28 +0000 Subject: [PATCH] Patch for jthreads --- src/scifem.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/scifem.cpp b/src/scifem.cpp index cfd8b58..72e1df8 100644 --- a/src/scifem.cpp +++ b/src/scifem.cpp @@ -423,13 +423,26 @@ std::tuple, std::vector> closest_point_projection( } else { +#ifdef __cpp_lib_jthread std::vector threads; +#else + std::vector threads; +#endif threads.reserve(num_threads); for (size_t i = 0; i < num_threads; ++i) { auto [c0, c1] = dolfinx::MPI::local_range(i, total_cells, num_threads); threads.emplace_back(compute_chunk, c0, c1); } +#ifndef __cpp_lib_jthread + for (auto& t : threads) + { + if (t.joinable()) + { + t.join(); + } + } +#endif } return {std::move(closest_points), std::move(reference_points)}; }