Q_PUSH(3)

πŸ’– Q_PUSH(3) β€” the Librecast Programmer's Manual, bestie edition πŸ’–

okay so welcome to the Librecast Programmer's Manual, page Q_PUSH(3) 🌸 pull up a chair, we're pushing jobs onto queues and it's gonna be iconic.


✨ NAME ✨

q_push β€” push a job onto a smolq queue 🫢

πŸ“š LIBRARY πŸ“š

Librecast library (liblibrecast, -llibrecast) πŸ’œ

🌈 SYNOPSIS 🌈

#include <librecast/q.h>

int  q_push(q_t *q, void *(*f)(void *), void *restrict arg);
int  q_trypush(q_t *q, void *(*f)(void *), void *restrict arg);

Compile and link with -llibrecast. no cap, you gotta have that flag ✨

πŸ‘‘ DESCRIPTION πŸ‘‘

So here's the tea, bestie πŸ“:

  • q_push() pushes f onto the queue q with argument arg. That's it. That's the whole vibe. πŸ’…
  • q_trypush() is literally the same as q_push() except that if the queue writer lock cannot be immediately obtained, then the call returns an error (errno set to EAGAIN) instead of blocking. she does NOT wait around, she's got places to be 😀
Like, q_push() will just stand there patiently until it can get in. q_trypush() is the "if you're not free in 0.2 seconds I'm leaving" friend πŸ™ˆ

⭐ RETURN VALUE ⭐

  • The q_push() function returns zero on success πŸŽ€
  • On error, -1 is returned and errno is set to indicate the error πŸ’€

πŸ¦‹ ERRORS πŸ¦‹

  • EAGAIN (q_trypush()) β€” The operation could not be performed without blocking. (i.e., the queue was full). she's FULL full, bestie 😭

The function can also fail with the errors for sem_post(3) or sem_wait(3). so go read those too, iykyk 🧚

🌸 SEE ALSO 🌸

q_job_seek(3), q_pool_create(3), q_pool_destroy(3), q_init(3), q_free(3), q_wait(3), sem_post(3), sem_wait(3) β€” the whole friend group, go say hi πŸ’–


and that's the page!! this one's from the LIBRECAST era, dated 2023-07-25, filed under Q_PUSH(3) πŸ‘‘ stay hydrated, read your semaphores, and go push some jobs bestie 🫢✨

πŸ“¦ where this page comes from