@@ -88,17 +88,19 @@ std::unique_ptr<ScrubJob> ScrubQueue::pop_ready_pg(
8888 jb->schedule .deadline <= time_now))));
8989 };
9090
91- auto not_ripes = rng::partition (to_scrub, eligible_filtr);
92- if (not_ripes.begin () == to_scrub.begin ()) {
91+ auto not_ripes =
92+ std::partition (to_scrub.begin (), to_scrub.end (), eligible_filtr);
93+ if (not_ripes == to_scrub.begin ()) {
9394 return nullptr ;
9495 }
95- auto top = rng::min_element (
96- to_scrub.begin (), not_ripes.begin (), rng::less (),
97- [](const std::unique_ptr<ScrubJob>& jb) -> utime_t {
98- return jb->get_sched_time ();
96+ auto top = std::min_element (
97+ to_scrub.begin (), not_ripes,
98+ [](const std::unique_ptr<ScrubJob>& lhs,
99+ const std::unique_ptr<ScrubJob>& rhs) -> bool {
100+ return lhs->get_sched_time () < rhs->get_sched_time ();
99101 });
100102
101- if (top == not_ripes. begin () ) {
103+ if (top == not_ripes) {
102104 return nullptr ;
103105 }
104106
@@ -129,21 +131,25 @@ std::set<spg_t> ScrubQueue::get_pgs(const ScrubQueue::EntryPred& cond) const
129131{
130132 std::lock_guard lck{jobs_lock};
131133 std::set<spg_t > pgs_w_matching_entries;
132- rng::transform (
133- to_scrub | std::views::filter (
134- [&cond]( const auto & job) -> bool { return (cond)(*job); }),
135- std::inserter (pgs_w_matching_entries, pgs_w_matching_entries. end ()),
136- []( const auto & job) { return job-> pgid ; });
134+ for ( const auto & job : to_scrub) {
135+ if ( cond (*job)) {
136+ pgs_w_matching_entries. insert ( job-> pgid );
137+ }
138+ }
137139 return pgs_w_matching_entries;
138140}
139141
142+
140143void ScrubQueue::for_each_job (
141144 std::function<void (const Scrub::ScrubJob&)> fn,
142145 int max_jobs) const
143146{
144147 std::lock_guard lck (jobs_lock);
145- std::ranges::for_each (
146- to_scrub | std::views::take (max_jobs),
148+ // implementation note: not using 'for_each_n()', as it is UB
149+ // if there aren't enough elements
150+ std::for_each (
151+ to_scrub.begin (),
152+ to_scrub.begin () + std::min (max_jobs, static_cast <int >(to_scrub.size ())),
147153 [fn](const auto & job) { fn (*job); });
148154}
149155
0 commit comments