Switch TaskMapOverInt to llvm::function_ref

The function does not persist the callback, so using a lighter-weight
asbtraction seems appropriate.

Also tweak the signatures of the lambdas to match what the TaskMap
interface expects.

llvm-svn: 304924
This commit is contained in:
Pavel Labath
2017-06-07 16:28:08 +00:00
parent 8ce1e3b759
commit 92f6677159
3 changed files with 5 additions and 5 deletions

View File

@@ -10,6 +10,7 @@
#ifndef utility_TaskPool_h_
#define utility_TaskPool_h_
#include "llvm/ADT/STLExtras.h"
#include <functional> // for bind, function
#include <future>
#include <list>
@@ -86,6 +87,6 @@ template <> struct TaskPool::RunTaskImpl<> {
// 'batch_size' numbers at a time to work on, so for very fast functions, batch
// should be large enough to avoid too much cache line contention.
void TaskMapOverInt(size_t begin, size_t end,
std::function<void(size_t)> const &func);
const llvm::function_ref<void(size_t)> &func);
#endif // #ifndef utility_TaskPool_h_

View File

@@ -1958,7 +1958,7 @@ void SymbolFileDWARF::Index() {
&function_fullname_index, &function_method_index,
&function_selector_index, &objc_class_selectors_index,
&global_index, &type_index,
&namespace_index](uint32_t cu_idx) {
&namespace_index](size_t cu_idx) {
DWARFCompileUnit *dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
if (dwarf_cu) {
dwarf_cu->Index(
@@ -1967,10 +1967,9 @@ void SymbolFileDWARF::Index() {
objc_class_selectors_index[cu_idx], global_index[cu_idx],
type_index[cu_idx], namespace_index[cu_idx]);
}
return cu_idx;
};
auto extract_fn = [debug_info, &clear_cu_dies](uint32_t cu_idx) {
auto extract_fn = [debug_info, &clear_cu_dies](size_t cu_idx) {
DWARFCompileUnit *dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
if (dwarf_cu) {
// dwarf_cu->ExtractDIEsIfNeeded(false) will return zero if the

View File

@@ -75,7 +75,7 @@ void TaskPoolImpl::Worker(TaskPoolImpl *pool) {
}
void TaskMapOverInt(size_t begin, size_t end,
std::function<void(size_t)> const &func) {
const llvm::function_ref<void(size_t)> &func) {
std::atomic<size_t> idx{begin};
size_t num_workers =
std::min<size_t>(end, std::thread::hardware_concurrency());