CK_BITMAP_BTS(3)

πŸ’– CK_BITMAP_BTS(3) β€” the Concurrency Kit manual, bestie edition πŸ’–

okay so. sit down. hydrate. we're talking about ck_bitmap_bts(3) from the Concurrency Kit, and honestly? she's a little icon. ✨


🌸 LIBRARY 🌸

Concurrency Kit β€” aka libck, and when you link her you use -lck. periodt.


✨ SYNOPSIS ✨

#include <ck_bitmap.h>

bool
ck_bitmap_bts(ck_bitmap_t *bitmap, unsigned int n);

like. look at her. two args. one bool. no drama. πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

ck_bitmap_bts() does the cutest little two-for-one: she sets the bit at the offset specified by the argument n to 1, and she fetches its original value on the way out. not me doing two jobs in one call, main character energy fr fr πŸ’…

so you get the new state (the bit is 1 now, bestie, that's done) and the old state, which is genuinely so useful if you're trying to figure out whether you were the one who flipped it or whether somebody else got there first. iykyk. πŸ”₯


πŸ‘‘ RETURN VALUES πŸ‘‘

This function returns the original value of the bit at offset n in bitmap.

read that again. the ORIGINAL value. not the new one. she already set it to 1, but she's telling you what it was before she touched it. that's the whole point of the bts and it's lowkey the most important sentence on this page. 😭

🌈 SEE ALSO 🌈

the whole bitmap friend group, all iconic, all worth a read:

Additional information available at http://concurrencykit.org/ 🫢


k bye bestie, go set some bits πŸ’–βœ¨

mwah πŸ’‹ β€” this page is from August 22, 2014, filed under CK_BITMAP_BTS(3), and that's on periodt.

πŸ“¦ where this page comes from