Factor out common code to a header.

llvm-svn: 288599
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 4a723d5..cfb8ac9 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -16,7 +16,7 @@
 #include "SymbolTable.h"
 #include "SyntheticSections.h"
 #include "Target.h"
-#include "lld/Core/Parallel.h"
+#include "Threads.h"
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/MathExtras.h"
@@ -254,10 +254,7 @@
     fill(Buf, this->Size, Filler);
 
   auto Fn = [=](InputSection<ELFT> *IS) { IS->writeTo(Buf); };
-  if (Config->Threads)
-    parallel_for_each(Sections.begin(), Sections.end(), Fn);
-  else
-    std::for_each(Sections.begin(), Sections.end(), Fn);
+  forEach(Sections.begin(), Sections.end(), Fn);
 
   // Linker scripts may have BYTE()-family commands with which you
   // can write arbitrary bytes to the output. Process them if any.