CK_EPOCH_REGISTER(3)

πŸ’– CK_EPOCH_REGISTER β€” bestie edition πŸ’–

okay so real talk, this is ck_epoch_register(3) from the Concurrency Kit crew β€” aka libck, and you link it in with -lck. it's the little function that says "hey epoch system, this thread is HERE and it needs safe memory reclamation, mkay?" 🫢


✨ SYNOPSIS ✨

#include <ck_epoch.h>

void
ck_epoch_register(ck_epoch_t *epoch, ck_epoch_record_t *record,
    void *cl);

🌸 DESCRIPTION 🌸

so like, ck_epoch_register(3) takes the record object you point at with record and associates it with the epoch object that epoch points to. that's the whole vibe.

here's the part you cannot skip, bestie: any thread or processor that wants safe memory reclamation guarantees has to register a unique record object. unique!! no sharing, no borrowing, no "we'll just reuse my friend's record" β€” one record per thread/processor, periodt. πŸ’…

once you've registered, the object that record points to gets its whole lifetime managed by the underlying epoch sub-system. which means:

🚨 do NOT destroy the record object after it's been associated with a ck_epoch_register(3) call. it's not yours anymore in that way. the epoch system is its parent now. 😭

and ooh, there's a lil bonus β€” you can pass an optional context pointer cl (as in, whatever you want, it's just a void *), and you can get it back later with the ck_epoch_record_ct(3) function. cute, right? a little pocket for your stuff. πŸŽ€


⭐ RETURN VALUES ⭐

ngl this one's the easiest section in the whole page: this function has no return value. it returns void. nothing. not even an int. slay. πŸ’€βœ¨


πŸ¦‹ SEE ALSO πŸ¦‹

the whole friend group, in order:

and if you want additional information, it's all chillin' at http://concurrencykit.org/ πŸ‘‘


okay that's the whole page!! this one was dated September 2, 2012 and lives under the name CK_EPOCH_REGISTER(3) β€” so like, shoutout to the original authors, the copyright holders, and whoever wrote the license for this beauty. πŸ’œ registering a record: iconic behavior. go off, bestie. πŸŒˆπŸ§šβ€β™€οΈ

πŸ“¦ where this page comes from