Q_WAIT(3)

πŸ’– Q_WAIT(3) β€” the Librecast Programmer's Manual glow-up πŸ’–

okay bestie, sit down, hydrate, because we're about to talk about q_wait from the Librecast Programmer's Manual and honestly? she's iconic. this is the page for pulling the next job off your queue and she does it with main character energy. no cap.


✨ NAME ✨

q_wait β€” return the next job from the queue, when available πŸŽ€


🌸 LIBRARY 🌸

Librecast library (liblibrecast, -llibrecast) πŸ¦‹


πŸ’… SYNOPSIS πŸ’…

#include <librecast/q.h>

int q_wait(q_t *q, q_job_t *job);
int q_trywait(q_t *q, q_job_t *job);

and like, you gotta compile and link with -llibrecast. don't forget it, that's the vibe check. ✨


🫢 DESCRIPTION 🫢

so q_wait() atomically fetches the next job in q and sets the job pointer to it. the call blocks until a job is available. literally she will just stand there, patiently, waiting for a job to show up, because she's loyal like that. πŸ‘‘

q_trywait() is the same as q_wait() β€” same energy, same job-fetching β€” except that if the queue read lock cannot be immediately obtained, then the call returns an error (errno set to EAGAIN) instead of blocking. she's not gonna wait around. she's like "lock's busy? okay byee πŸ’€" and hands you an error instead.

so real talk: q_wait() = patient queen, q_trywait() = girl who does not wait. pick based on whether you want to block or not. πŸŽ€

πŸ‘‘ RETURN VALUE πŸ‘‘

The q_push() function returns zero on success. On error, -1 is returned and errno is set to indicate the error.

ngl the page literally says q_push() here β€” that's what it says, i'm not making it up, i'm just the messenger bestie 😭 i'm reporting it exactly as written, character for character. πŸ™ˆ

πŸ’€ ERRORS πŸ’€

The function can also fail with the errors for sem_post(3) or sem_wait(3). so if something goes sideways, those are the places to look, fr fr.


🌈 SEE ALSO 🌈


and that's the whole page, bestie!! πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ

this lil masterpiece is from LIBRECAST, dated 2023-07-25, and it's page Q_WAIT(3) β€” like, that's the source, the version and the date, all wrapped up in a bow πŸŽ€πŸ«Ά go forth and wait on your queues, queen. periodt. πŸ’…πŸ‘‘

πŸ“¦ where this page comes from