qthread_writeEF(3)

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

✨ qthread_writeEF(3) ✨

okay bestie, pull up a chair, we're reading the libqthread manual together and this one is genuinely iconic 🫢 it's the qthread_writeEF page, and yes there's a _const twin, they're a package deal πŸ’…


🌸 NAME 🌸

qthread_writeEF, qthread_writeEF_const β€” waits for the dest to be empty, then fills it. that's it. that's the whole vibe. wait for empty, then fill. πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <qthread.h>

int
qthread_writeEF (aligned_t * restrict dest, const aligned_t * restrict
src);

int
qthread_writeEF_const (aligned_t *dest, aligned_t src);

πŸŽ€ DESCRIPTION πŸŽ€

so like, these functions wait for memory to become empty, and then fill it. the way that works is: when the memory becomes empty, only one thread that's blocked like this gets awoken. not two, not a crowd, one. main character energy only πŸ‘‘

data is read from src and written to dest. simple. slay.

the semantics of writeEF are, in order, no skipping:

  1. dest's FEB state must be "empty"
  2. data is copied from src to dest
  3. dest's FEB state gets changed from "empty" to "full"

periodt. that's the whole pipeline. 🌈


πŸ’€ WARNING πŸ’€

okay so this is the part where I hold your hand, because it's giving "read this or perish" πŸ™ˆ

This, and all other FEB-related functions currently operate exclusively on aligned data. This is to simulate the behavior of the MTA as closely as possible. If the library was compiled for a 32-bit architecture, it will require 4-byte alignment and reads/writes will operate on four bytes at a time; if the library was compiled for a 64-bit architecture, it will require 8-byte alignment and reads/writes will operate on eight bytes at a time.

bestie. alignment is not a suggestion here, it's a personality requirement. get it wrong and you're on your own 😭

⭐ RETURN VALUE ⭐

On success, the memory address dest is marked full, the address dest is filled with the contents of src, and 0 is returned. πŸŽ‰

On error, a non-zero error code is returned. that's the "we don't talk about it" branch. πŸ’…


πŸ“ ERRORS πŸ“

  • ENOMEM β€” Not enough memory could be allocated for bookkeeping structures. lowkey tragic. the bookkeeping could not be booked. 😭

🧚 SEE ALSO 🧚

go read those too, they're all in the same friend group πŸ’œ


and that's the page!! this whole thing came out of libqthread, dated APRIL 2011 β€” shoutout to the source and the version and the date, they ate and left no crumbs πŸ‘‘πŸ’– byeeee, go write to your dest responsibly 🫢✨

πŸ“¦ where this page comes from