| 3 | #include "include/UTL/parallel.hpp" |
| 4 | |
| 5 | int main() { |
| 6 | using namespace utl; |
| 7 | using namespace std::chrono_literals; |
| 8 | |
| 9 | // Run loop on the main thread |
| 10 | UTL_PROFILER("Single-threaded loop") |
| 11 | for (int i = 0; i < 30; ++i) std::this_thread::sleep_for(10ms); |
| 12 | |
| 13 | // Run the same loop on 3 threads |
| 14 | parallel::set_thread_count(3); |
| 15 | |
| 16 | UTL_PROFILER("Multi-threaded loop") |
| 17 | parallel::blocking_loop(parallel::IndexRange{0, 30}, [](int low, int high){ |
| 18 | UTL_PROFILER("Worker thread loop") |
| 19 | for (int i = low; i < high; ++i) std::this_thread::sleep_for(10ms); |
| 20 | }); |
| 21 | |
| 22 | parallel::set_thread_count(0); |
| 23 | } |
nothing calls this directly
no test coverage detected