gdbsupport: use iterator range in parallel_for_each interface

I think it would be convenient for parallel_for_each to pass an
iterator_range to the worker function, instead of separate begin and end
parameters.  This allows using a ranged for loop directly.

Change-Id: I8f9681da65b0eb00b738379dfd2f4dc6fb1ee612
Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
Simon Marchi
2025-09-19 16:27:02 -04:00
parent bb16b12f0e
commit 0f5b90c2dc
3 changed files with 27 additions and 26 deletions

View File

@@ -23,6 +23,7 @@
#include <algorithm>
#include <atomic>
#include <tuple>
#include "gdbsupport/iterator-range.h"
#include "gdbsupport/thread-pool.h"
namespace gdb
@@ -114,7 +115,7 @@ parallel_for_each (const RandomIt first, const RandomIt last,
static_cast<size_t> (this_batch_first - first),
static_cast<size_t> (this_batch_last - first));
worker (this_batch_first, this_batch_last);
worker ({ this_batch_first, this_batch_last });
}
};
@@ -138,7 +139,7 @@ sequential_for_each (RandomIt first, RandomIt last, WorkerArgs &&...worker_args)
if (first == last)
return;
Worker (std::forward<WorkerArgs> (worker_args)...) (first, last);
Worker (std::forward<WorkerArgs> (worker_args)...) ({ first, last });
}
}