CK_RHS_MOVE(3)

πŸ’– ck_rhs_move β€” move one from hash set to another πŸ’–

okay bestie, welcome to ck_rhs_move(3) β€” yes that's the section 3 manual, we're in the library pages now, it's giving deep internals and honestly? iconic. 🫢

This one lives in the Concurrency Kit β€” that's libck, and you link it with -lck. πŸŽ€


✨ SYNOPSIS ✨

#include <ck_rhs.h>

bool
ck_rhs_move(ck_rhs_t *destination, ck_rhs_t *source,
    ck_rhs_hash_cb_t *hash_cb, ck_rhs_compare_cb_t *compare_cb,
    struct ck_malloc *m);

like, four pointers and a callback struct, we been knew πŸ’…


🌸 DESCRIPTION 🌸

so ck_rhs_move(3) initializes source from destination. yes, that's the direction. read it again, it's not a typo, it's literally the whole point of this function, no cap. ✨

While it's doing that, it also re-wires the callbacks for you:

  • the hash function gets set to hash_cb
  • the comparison function gets set to compare_cb
  • the allocator callbacks get set to m
⚠️ okay now the serious part, bestie, listen up: further modifications to source will result in undefined behavior. undefined behavior is not a vibe. it is the opposite of a vibe. do not do it. 😭

Concurrent ck_rhs_get(3) and ck_rhs_fas(3) operations to source are legal β€” but only until the next write operation to destination. so there's a little window where reads are fine, and then the window closes. respect the window. πŸ¦‹

🧚 what is this actually for tho

This operation moves ownership from one hash set object to another, and re-assigns callback functions to developer-specified values. 🌈

Which means: you get to dynamically configure allocation callbacks. slay.

And it's necessary for use-cases involving executable code which may be unmapped underneath the hash set β€” like, the code can just vanish out from under it and this is how you cope. main character survival energy fr fr. πŸ‘‘


⭐ RETURN VALUES ⭐

  • true β€” upon successful completion, ck_rhs_move(3) returns true. ate. πŸ’–
  • false β€” otherwise it returns false to indicate an error. πŸ™ˆ

that's it. two outcomes. binary. she's simple like that.


πŸ‘‘ SEE ALSO πŸ‘‘

go read these too, they're all in the family, it's a whole friend group:

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


and that's the page!! this one was dated July 18, 2013, and it's page CK_RHS_MOVE(3) in the Concurrency Kit manual β€” so yeah, she's been serving hash set relocation realness since 2013 and she's still here. periodt. πŸ’œβœ¨

πŸ“¦ where this page comes from