CK_PR_ADD(3)

πŸ’– ck_pr_add(3) β€” atomic addition operations πŸ’–

okay bestie, so this is ck_pr_add(3), and it lives in the Concurrency Kit (that's libck, and you link it with -lck). It's a whole little family of functions that add stuff atomically, and honestly? it's giving "no data races, only vibes." ✨


🌸 SYNOPSIS 🌸

#include <ck_pr.h>

void
ck_pr_add_ptr(void *target, uintptr_t delta);

void
ck_pr_add_double(double *target, double delta);

void
ck_pr_add_char(char *target, char delta);

void
ck_pr_add_uint(unsigned int *target, unsigned int delta);

void
ck_pr_add_int(int *target, int delta);

void
ck_pr_add_64(uint64_t *target, uint64_t delta);

void
ck_pr_add_32(uint32_t *target, uint32_t delta);

void
ck_pr_add_16(uint16_t *target, uint16_t delta);

void
ck_pr_add_8(uint8_t *target, uint8_t delta);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea πŸ“: the whole ck_pr_add(3) family does exactly one thing and does it flawlessly. It atomically adds the value you pass in delta to the value sitting at the address pointed to by target.

that's it. that's the whole job. no cap. πŸ”₯

"atomically" means nobody can catch it mid-add β€” other threads either see the old value or the new one, never some cursed in-between situation. main character energy, fr fr. πŸ‘‘

πŸ’€ heads up: pick the right function for your type. ck_pr_add_8 wants a uint8_t, ck_pr_add_ptr wants a void * and a uintptr_t delta, and so on β€” nine flavours, one for each type in the synopsis. Don't mix and match, bestie.

⭐ RETURN VALUES ⭐

ngl, this family of functions does not have a return value. It's void, periodt. πŸ’… It just does the thing and dips. ✨


🌈 SEE ALSO 🌈

like, go meet the whole friend group 🫢:

and if you want even more lore, additional information is available at http://concurrencykit.org/ 🧚


that's the whole page, bestie β€” written by the Concurrency Kit girlies back on April 11, 2013, and yes she's still iconic. ck_pr_add(3), out. πŸ’œβœ¨

πŸ“¦ where this page comes from