qthread_queue_create(3)
β¨ qthread_queue_create β bestie we're building sync queues β¨
okay so this page lives in the libqthread manual, and it's all about qthread_queue_create(3) and its partner in crime qthread_queue_destroy(3). pull up a chair, we're gonna talk about synchronization queues π
πΈ NAME πΈ
qthread_queue_create β allocate and/or initialize a synchronization queue π
π¦ SYNOPSIS π¦
#include <qthread.h>
qthread_queue_t
qthread_queue_create (uint8_t flags,
aligned_t length);
int
qthread_queue_destroy (qthread_queue_t q);
π DESCRIPTION π
so these two functions are the allocating and deallocating girlies for qthread_queue_t objects. qthread_queue_create() allocates and initializes a qthread_queue_t object, and qthread_queue_destroy() deallocates one. periodt. π«Ά
these objects are generic synchronization building blocks β like, they're designed specifically for implementing other synchronization objects. you can use them to implement mutexes, FEBs, and even sincs, and it's actually pretty efficient, given that you also have to initialize and destroy the associated bookkeeping structure. the only thing that changes between all those use cases is how the queue is used. iykyk β¨
the creation function takes two arguments: flags and length. the flags may be any of the following:
QTHREAD_QUEUE_NO_SYNCβ this says the queue should employ no synchronization. all the sync gets done externally, if you even need it, to make sure access to both joining and releasing the queue is exclusive. the queue can have any number of entries. no cap.QTHREAD_QUEUE_MULTI_JOINβ this says the queue should expect to have multiple concurrent, asynchronous join operations. those join operations are safe to execute in parallel, but the release operation is not safe to run in parallel with the join operations. the queue can have any number of entries.QTHREAD_QUEUE_MULTI_JOIN_LENGTHβ same energy as above: the queue should expect multiple concurrent, asynchronous join operations, and it should keep track of the length of the queue. those joins are safe to execute in parallel, but again, the release operation is not safe to run in parallel with the joins. the queue can have any number of entries.QTHREAD_QUEUE_CAPPEDβ this one says the queue should, like theMULTI_JOINoptions, be safe to join in parallel, but also that there's a maximum number of elements in the queue. the slay here is that it lets the join operation be faster, because it doesn't need to allocate memory. π₯
the length argument is only applicable for QTHREAD_QUEUE_CAPPED, and it specifies the fixed length of the queue. that's it, that's the whole job.
π RETURN VALUES π
qthread_queue_create()returns an initializedqthread_queue_tobject. iconic. πqthread_queue_destroy()returnsQTHREAD_SUCCESSon success, and an error otherwise. π
π SEE ALSO π
qthread_queue_destroy(3)qthread_queue_join(3)qthread_queue_length(3)qthread_queue_release_all(3)qthread_queue_release_one(3)
go read those too bestie, they're the whole friend group π¦
and that's the vibe check, bestie π this page came from libqthread, dated AUGUST 2013 β yeah it's a vintage queen but she still ate. now go forth and build your synchronization objects, main character. mwah π
β¨
π¦ 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