qthread_worker_unique(3)

πŸ“¦ version 1.22^20251007gitcedb1fc, in fedora 43, fedora 44

πŸ’– qthread_worker_unique β€” a libqthread moment πŸ’–

okay bestie, gather round, because this little function from the libqthread manual (section 3, we're fancy) is literally about to tell you where you're standing on the worker grid. no cap.


✨ NAME ✨

qthread_worker_unique β€” returns the qthread's current worker's stable ID 🫢


🌸 SYNOPSIS 🌸

#include <qthread.h>

qthread_worker_id_t
qthread_worker_unique (qthread_shepherd_id_t *shep);

like. that's it. that's the whole vibe. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so the way this works is, this function hands you the stable ID of the worker that your current thread is executing on. that's it. that's the girl. ✨

and if shep is non-NULL, then the value of the current shepherd identifier gets written to that location too β€” so you get a lil two-for-one deal, worker ID and shepherd ID, iconic behavior honestly πŸ‘‘

⚠️ ok but real talk, bestie, listen: the current worker ID is transient. it is likely to change. like, for example, after a call to qthread_yield() it might just be a whole different number. so do not be out here storing it in your little diary and expecting it to still be true later. it's giving main character who moves schools mid-season 😭

also important, and this one's lowkey subtle: this value is not dependent on how many workers have been disabled. so whatever chaos is happening with disabled workers, this number doesn't care. it's unbothered. it's above it. periodt. πŸ’…


🌈 RETURN VALUE 🌈

this function either returns:

  • the ID number of the current worker of the calling function, or
  • NO_WORKER πŸ«₯

that's the whole menu, bestie. one or the other. no in-between.


πŸŽ€ SEE ALSO πŸŽ€

go read those too, they're all part of the same friend group fr fr 🧚


mwah πŸ’‹ this lil page came to you from libqthread, dated JUNE 2011 β€” yeah she's vintage, she's a classic, and she still ate. slay. πŸ’œ

πŸ“¦ where this page comes from