CK_EPOCH_RECLAIM(3)

πŸ’– CK_EPOCH_RECLAIM(3) β€” bestie edition πŸ’–

okay so this is the manual page for ck_epoch_reclaim(3), part of Concurrency Kit (aka libck, link it with -lck) πŸŽ€


✨ NAME ✨

ck_epoch_reclaim β€” immediately execute all deferred callbacks 🫢

like, right now. no waiting. no vibes-based delay. just do them.


πŸ“š LIBRARY πŸ“š

Concurrency Kit (libck, -lck) πŸ‘‘


🌸 SYNOPSIS 🌸

#include <ck_epoch.h>

void
ck_epoch_reclaim(ck_epoch_record_t *record);

πŸ’… DESCRIPTION πŸ’…

so the ck_epoch_reclaim(3) function will unconditionally execute all callbacks that have been deferred with ck_epoch_call(3) ✨

that's it. that's the whole function. she does not ask questions, she does not check the vibes, she does not wait for the grace period to be over on her own β€” she just runs every single deferred callback you handed her. periodt πŸ’…

ngl bestie, "unconditionally" is doing a lot of heavy lifting in that sentence. she runs them because you said so, not because it was safe. iykyk 😭

πŸ¦‹ EXAMPLE πŸ¦‹

#include <ck_epoch.h>
#include <ck_stack.h>
#include <stdlib.h>

/*
 * epoch was previously initialized with ck_epoch_init.
 */
ck_epoch_t *epoch;

void
function(void)
{
        ck_epoch_record_t *record;

        logically_delete(object);
        ck_epoch_call(epoch, record, &object->epoch_entry, destructor);

        /*
         * Wait until no threads could possibly have a reference to the
         * object we just deleted.
         */
        ck_epoch_synchronize(epoch, record);

        /*
         * Execute all deferred callbacks.
         */
        ck_epoch_reclaim(record);

        return;
}

see how she goes? logically delete the object 🌸, defer the real cleanup with ck_epoch_call(3) πŸŽ€, synchronize so nobody could possibly still be holding a reference 😌, and then β€” only then β€” ck_epoch_reclaim(record) to actually run every deferred callback. the way that order matters… iconic. πŸ”₯


⭐ RETURN VALUES ⭐

this function has no return value. she gives you nothing back and honestly? she doesn't have to. 🫢


🌈 SEE ALSO 🌈

more lore available at http://concurrencykit.org/ 🧚


Concurrency Kit, May 2, 2013 β€” that's the source/version and the date this page was born, and that's a wrap bestie πŸ’œ go execute those callbacks (safely, please) πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from