File size: 587 Bytes
57c2394
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#pragma once

#include <cstdint>
#include <functional>
#include <utility>
#include <vector>

namespace orbitquant::cpu {

// Executes fn over each [start, end) range using a lazily created persistent
// worker pool plus the calling thread. Ranges are disjoint, so results stay
// deterministic regardless of which thread runs which range. A single range
// (or an empty pool) runs inline on the caller.
void run_ranges(
    std::vector<std::pair<std::int64_t, std::int64_t>> const &ranges,
    std::function<void(std::int64_t, std::int64_t)> const &fn);

}  // namespace orbitquant::cpu