CK_HS_MOVE(3)

πŸ’– ck_hs_move(3) β€” move one from hash set to another πŸ’–

okay bestie, gather round, because this little function is lowkey a whole vibe shift for your hash sets πŸ¦‹

πŸ“š LIBRARY

Concurrency Kit (that's libck, link it with -lck) πŸ’…


✨ SYNOPSIS ✨

#include <ck_hs.h>

bool
ck_hs_move(ck_hs_t *destination, ck_hs_t *source,
    ck_hs_hash_cb_t *hash_cb, ck_hs_compare_cb_t *compare_cb,
    struct ck_malloc *m);

no cap, that's the whole signature. five args. she's efficient. πŸ‘‘


🌸 DESCRIPTION 🌸

so the tea is: ck_hs_move(3) will initialize source from destination. yep, that's the direction, don't come for me, that's literally what the page says. 🫢

while she's doing that, the hash function gets set to hash_cb, the comparison function gets set to compare_cb, and the allocator callbacks get set to m. it's giving "glow up with a whole new callback wardrobe." ✨

🚨 bestie, listen: further modifications to source will result in undefined behavior. like, don't. it's not a "try it and see" situation, it's a "put the keyboard down" situation. 😭

but here's the good news β€” concurrent ck_hs_get(3) and ck_hs_fas(3) operations to source are legal until the next write operation to destination. read-only girlies, you're safe. πŸ’–

what is this actually doing though? this operation moves ownership from one hash set object to another, and re-assigns callback functions to developer-specified values. slay. that means you get dynamic configuration of allocation callbacks, which is necessary for use-cases involving executable code which may be unmapped underneath the hash set. (imagine your code getting yanked out from under you mid-hash β€” yeah, that's why this exists. main character problem-solving energy, fr fr. 🧚)


πŸŽ€ RETURN VALUES πŸŽ€

  • upon successful completion, ck_hs_move(3) returns true β€” ate, no crumbs πŸ“
  • otherwise it returns false to indicate an error β€” not the vibe, but at least she tells you πŸ’€

πŸ‘€ SEE ALSO πŸ‘€

the whole friend group, in order, because they roll together:

additional information available at http://concurrencykit.org/ 🌈


mwah, that's a wrap bestie πŸ’œ this one dropped July 18, 2013 and it lives in the CK_HS_MOVE(3) corner of the manual, brought to you by the Concurrency Kit girlies. periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from