summaryrefslogtreecommitdiff
path: root/gnu/llvm/tools/lld/ELF/Threads.h
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/llvm/tools/lld/ELF/Threads.h')
-rw-r--r--gnu/llvm/tools/lld/ELF/Threads.h30
1 files changed, 16 insertions, 14 deletions
diff --git a/gnu/llvm/tools/lld/ELF/Threads.h b/gnu/llvm/tools/lld/ELF/Threads.h
index 9feb8683976..c03e15253e1 100644
--- a/gnu/llvm/tools/lld/ELF/Threads.h
+++ b/gnu/llvm/tools/lld/ELF/Threads.h
@@ -15,7 +15,7 @@
//
// That said, we don't want to do "too clever" things using threads.
// Complex multi-threaded algorithms are sometimes extremely hard to
-// reason about and can easily mess up the entire design.
+// justify the correctness and can easily mess up the entire design.
//
// Fortunately, when a linker links large programs (when the link time is
// most critical), it spends most of the time to work on massive number of
@@ -34,7 +34,7 @@
// instead of std::for_each (or a plain for loop). Because tasks are
// completely independent from each other, we can run them in parallel
// without any coordination between them. That's very easy to understand
-// and reason about.
+// and justify.
//
// For the cases such as the latter, we can use parallel algorithms to
// deal with massive data. We have to write code for a tailored algorithm
@@ -61,28 +61,30 @@
#include "Config.h"
-#include "llvm/Support/Parallel.h"
+#include "lld/Core/Parallel.h"
+#include <algorithm>
#include <functional>
namespace lld {
namespace elf {
template <class IterTy, class FuncTy>
-void parallelForEach(IterTy Begin, IterTy End, FuncTy Fn) {
+void forEach(IterTy Begin, IterTy End, FuncTy Fn) {
if (Config->Threads)
- for_each(llvm::parallel::par, Begin, End, Fn);
+ parallel_for_each(Begin, End, Fn);
else
- for_each(llvm::parallel::seq, Begin, End, Fn);
+ std::for_each(Begin, End, Fn);
}
-inline void parallelForEachN(size_t Begin, size_t End,
- std::function<void(size_t)> Fn) {
- if (Config->Threads)
- for_each_n(llvm::parallel::par, Begin, End, Fn);
- else
- for_each_n(llvm::parallel::seq, Begin, End, Fn);
+inline void forLoop(size_t Begin, size_t End, std::function<void(size_t)> Fn) {
+ if (Config->Threads) {
+ parallel_for(Begin, End, Fn);
+ } else {
+ for (size_t I = Begin; I < End; ++I)
+ Fn(I);
+ }
+}
+}
}
-} // namespace elf
-} // namespace lld
#endif