Table of Contents

Name

qt_loop - a simple implementation of a threaded loop

Synopsis

#include <qthread/qloop.h>

void
qt_loop(const size_t start, const size_t stop, const size_t stride, const qthread_f func, void *argptr);

Description

This function provides a simple C implementation of a threaded loop. This is similar to mt_loop, but does not provide much of the convenience and isomorphism that a C++ implementation can provide. On the other hand, it is more portable, and more predictable.

This function can be thought of as akin to the following code:

unsigned int i;
for (i = start; i < stop; i += stride) {


func(NULL, argptr);

}

A qthread is spawned for every iteration of the above loop. Thus, if start is 50, stop is 100, and stride is 1, there will be 50 qthreads. But, if start is 50, stop is 100, and stride is 2, there will be 25 qthreads.

The func argument must be a function pointer with a qthread_f prototype, such as:

aligned_t func(qthread_t *me, void *arg);

The return value of this function is ignored. However, qt_loop will not return until all of the qthreads it spawns have returned.

See Also

qt_loop_future(3) , qt_loop_balance(3) , qt_loop_balance_future(3) , qt_loopaccum_balance(3) , qt_loopaccum_balance_future(3)


Table of Contents