56 static typename std::enable_if<t_max_number_of_threads <= 32, void>::type
ThreadLoop(
uint04 number_of_loops,
const std::function<
void(
uint04 index)>& callback)
58 volatile uint04 loops_performed = 0;
59 switch (
getMin(t_max_number_of_threads, number_of_loops))
62 case 1: ThreadLoop<1>(number_of_loops, loops_performed, callback);
break;
63 case 2: ThreadLoop<2>(number_of_loops, loops_performed, callback);
break;
64 case 3: ThreadLoop<3>(number_of_loops, loops_performed, callback);
break;
65 case 4: ThreadLoop<4>(number_of_loops, loops_performed, callback);
break;
66 case 5: ThreadLoop<5>(number_of_loops, loops_performed, callback);
break;
67 case 6: ThreadLoop<6>(number_of_loops, loops_performed, callback);
break;
68 case 7: ThreadLoop<7>(number_of_loops, loops_performed, callback);
break;
69 case 8: ThreadLoop<8>(number_of_loops, loops_performed, callback);
break;
70 case 9: ThreadLoop<9>(number_of_loops, loops_performed, callback);
break;
71 case 10: ThreadLoop<10>(number_of_loops, loops_performed, callback);
break;
72 case 11: ThreadLoop<11>(number_of_loops, loops_performed, callback);
break;
73 case 12: ThreadLoop<12>(number_of_loops, loops_performed, callback);
break;
74 case 13: ThreadLoop<13>(number_of_loops, loops_performed, callback);
break;
75 case 14: ThreadLoop<14>(number_of_loops, loops_performed, callback);
break;
76 case 15: ThreadLoop<15>(number_of_loops, loops_performed, callback);
break;
77 case 16: ThreadLoop<16>(number_of_loops, loops_performed, callback);
break;
78 case 32: ThreadLoop<32>(number_of_loops, loops_performed, callback);
break;
79 default:
lib_assert(
false,
"Invalid thread count");
return;
85 if constexpr (t_max_number_of_threads == 1)
87 while (loops_performed < number_of_loops)
89 uint04 loop = ConcurrentOperation::increment(loops_performed);
90 if(loop - 1 < number_of_loops)
97 [&callback, &loops_performed, number_of_loops]
99 ThreadLoop<t_max_number_of_threads / 2>(number_of_loops, loops_performed, callback);
101 [&callback, &loops_performed, number_of_loops]
103 ThreadLoop<t_max_number_of_threads - (t_max_number_of_threads / 2)>(number_of_loops, loops_performed, callback);