qthread_worker(3)
π qthread_worker β bestie edition π
okay so this is a page from libqthread and it's literally the manual for qthread_worker, which tells you what worker ID your current thread is vibing on. short page, huge energy. let's get into it β¨
πΈ NAME πΈ
qthread_worker β returns the qthread's current worker ID π«Ά
β¨ SYNOPSIS β¨
#include <qthread.h>
qthread_worker_id_t
qthread_worker (qthread_shepherd_id_t *shep);
like, that's the whole thing. iconic honestly π
π¦ DESCRIPTION π¦
okay so qthread_worker hands you back the ID of the worker that the current thread is executing on. that's it, that's the job. main character behavior.
and here's the cute little bonus: if shep is non-NULL, then the value of the current shepherd identifier gets written to that location. so you can walk away with both pieces of info in one call. slay π
β οΈ okay important bestie, listen: the current worker ID is transient. like, it's likely to change. for example, after a call to qthread_yield(). do not get attached. do not store it in your diary. it's giving "you blinked and it's a different worker."
also, that value is dependent on how many workers are currently active. so the number you get depends on the current situation, not some fixed forever-number. iykyk π₯
π RETURN VALUE π
this function either:
- returns the ID number of the current worker of the calling function, or
- returns
NO_WORKER
that's the whole menu. either you get a worker ID or you get NO_WORKER, no in-between, no crumbs π
π SEE ALSO π
pthread_getspecific(3)qthread_retloc(3)pthread_shep(3)qthread_stackleft(3)qthread_id(3)
go read those too, they're all part of the same little family π§
k byeeee, this page came from libqthread and it's dated JUNE 2011 β old but still absolutely serving. 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