qt_loop_queue_create(3)
π qt_loop_queue_create β a libqthread joint, section 3, bestie π
okay so real quick: this page lives in the libqthread manual, section 3, and it's literally all about one function. sit down, grab a strawberry π, we're doing this.
β¨ NAME β¨
qt_loop_queue_create β allocate a loop queue handle π
π¦ SYNOPSIS π¦
#include <qthread/qloop.h>
qqloop_handle_t*
qt_loop_queue_create(
const qt_loop_queue_type type,
const size_t start,
const size_t stop,
const size_t step,
const qt_loop_f func,
void * const argptr);
that's the whole vibe right there, no cap π
πΈ DESCRIPTION πΈ
so this function allocates a loop queue handle that you then get to use with qt_loop_queue_run() or qt_loop_queue_run_there(). it's giving "make me a handle so i can actually run the thing" β¨
okay now the important part, bestie. the func argument has to be a function pointer with a qt_loop_f prototype, and its basic code structure is expected to look like this:
void func (const size_t startat, const size_t stopat, const
size_t step, void * arg)
{
for (unsigned int i = startat; i < stopat; i += step) {
/* do work */
}
}
so startat and stopat? those are decided by the library, not you π«Ά the library tells your function which range of i values (aka iterations) it's responsible for. you don't pick, you just vibe with what you're handed.
now the type argument β this one is the main character honestly. it defines which adaptive scheduling technique gets used to schedule the processing of loop iterations. the possible values are:
CHUNKβ the lowest-overhead method, but also the least adaptive. the library picks a small default chunk size, and all the available worker threads chew through loop iterations in groups of that size. you can set the chunk size yourself withqt_loop_queue_setchunk(). simple, speedy, not fancy πGUIDEDβ an implementation of guided self-scheduled loops, invented by Constantine D. Polychronopoulos and David J. Kuck back in 1987. iterations run in chunks that get halved in size as the loop progresses. this is particularly efficient at slightly imbalanced loops β it's giving "i adjust, but gently" πFACTOREDβ an implementation of factored self-scheduled loops, invented by Susan F. Hummel, and Edith Schonberg, and Lawrence E. Flynn in 1992. iterations run in chunks specified in sets. first, half of the iteration space is handed out in equal-sized chunks to all threads, then half of the remaining iterations get handed out in equal-sized chunks, and so forth. this is more effective thanGUIDEDwhen loops are more imbalanced π₯TIMEDβ an implementation of timed self-scheduled loops. iterations get timed, and subsequent chunks of iterations are given to worker threads based on how long the previous iteration chunks took. this method can account for overhead better and can potentially handle wildly imbalanced loops more efficiently thanFACTORED. the overachiever of the group, honestly π
π RETURN VALUES π
you get a pointer to a valid qqloop_handle_t back OR a NULL pointer if memory could not be allocated. that's it, that's the deal. if you see NULL, bestie, memory said no π
π§ SEE ALSO π§
and that's the whole page!! go forth and queue your loops, you absolute icon π β¨
libqthread Β· APRIL 2011 Β· qt_loop_queue_create(3) β periodt, that's a wrap ππ
π¦ where this page comes from
- fedora 43: qthreads-devel 1.22^20251007gitcedb1fc-1.fc43 Β· BSD-3-Clause AND MIT AND dtoa
- fedora 44: qthreads-devel 1.22^20251007gitcedb1fc-2.fc44 Β· BSD-3-Clause AND MIT AND dtoa
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms