qthread_syncvar_readFE(3)
π qthread_syncvar_readFE β from libqthread (section 3) π
okay bestie, sit down, hydrate, and let's talk about the most dramatic little function in libqthread π«Ά
β¨ NAME β¨
qthread_syncvar_readFE β she waits for the syncvar to be full, then copies its data and empties it π
πΈ SYNOPSIS πΈ
#include <qthread.h>
int
qthread_syncvar_readFE (uint64_t * restrict dest, syncvar_t * restrict
src);
π¦ DESCRIPTION π¦
So here's the vibe: this function waits for memory to become full, and then empties it. That's the whole personality. π
When memory becomes full, only one thread blocked like this will be awoken. Not two. Not "whoever gets there first." One. The others stay seated, bestie. π
Data is read from src and stored in dest. And here's the cute part β dest may be NULL, in which case the data will not be copied. She just empties. No notes. π
The semantics of readFE are, in order:
src's FEB state must be"full"β- data is copied from
srctodestβ¨ src's FEB state gets changed from"full"to"empty"π
it's giving full β copy β empty, and honestly? iconic. periodt.
π₯ RETURN VALUE π₯
On success: the memory address src is marked empty, the memory address dest is filled with the contents of src, and 0 (QTHREAD_SUCCESS) is returned. slay. π
On error: a non-zero error code is returned. not slay, but at least you know. π
π ERRORS π
ENOMEMβ Not enough memory could be allocated for bookkeeping structures. she tried to set up her little admin and there was just nothing left in the budget. πQTHREAD_TIMEOUTβ Could not obtain the lock on thesyncvar_t's status bits. This may be caused by many things, including memory corruption, an invalid syncvar, or even absurdly excessive contention (because it's protected by a naive spinlock rather than a fair spinlock). ngl, the naive spinlock is the villain of this story. π
π SEE ALSO π
qthread_syncvar_empty(3)qthread_syncvar_fill(3)qthread_syncvar_writeFE(3)qthread_syncvar_writeF(3)qthread_syncvar_readFF(3)qthread_syncvar_status(3)
go read the whole friend group, they're all connected iykyk π
π cute sign-off: this page came from libqthread, dated APRIL 2011 β yes she's vintage, yes she still ate. 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