[Common] Threads: use function_ref instead of std::function

The benefits are:

a) Performance (very minor): it removes a heap allocation of the std::function constructor (template<class F> function(F f))
b) Clarity: it suggests that the callable's lifetime should end after the callee returns. Such callback is widely used in llvm. lld also uses it a lot.

Reviewers: ruiu, rnk, pcc

Reviewed By: ruiu

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D54813

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@347620 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/lld/Common/Threads.h b/include/lld/Common/Threads.h
index 8545907..1425abd 100644
--- a/include/lld/Common/Threads.h
+++ b/include/lld/Common/Threads.h
@@ -74,7 +74,7 @@
 }
 
 inline void parallelForEachN(size_t Begin, size_t End,
-                             std::function<void(size_t)> Fn) {
+                             llvm::function_ref<void(size_t)> Fn) {
   if (ThreadsEnabled)
     for_each_n(llvm::parallel::par, Begin, End, Fn);
   else