void
qt_loop_balance(const size_t start, const size_t stop, const qt_loop_f
func, void *argptr);
void
qt_loop_balance_future(const size_t start, const size_t stop, const qt_loop_f
func, void *argptr);
These function can be thought of as akin to the following code:
unsigned int i;
for (i = start; i < stop; i ++) {func(NULL, argptr);}
One qthread (or future) is spawned for each shepherd. The set of values of i (iterations) is divided evenly among the shepherds, and each qthread (or future) is assigned a set of iterations to perform.
The func argument must be a function pointer with a qt_loop_f prototype. Its basic code structure is expected to look like this:
void func(qthread_t *me, const size_t startat, const size_t stopat, void *arg)
{for (unsigned int i = startat; i < stopat; i++) {}/* do work */}
The arguments startat and stopat are determined by the library, and tell the function what range of i values (iterations) it is responsible for. qt_loop_balance and qt_loop_balance_future will not return until all of the qthreads (or futures) it spawned have exited.