CK_EPOCH_CALL(3)
π CK_EPOCH_CALL(3) β the "do it later bestie" manual page π
okay so welcome to the ck_epoch_call page from the Concurrency Kit manual, aka libck, and bestie I'm gonna hold your hand through every single line of it, no cap. β¨
πΈ NAME πΈ
ck_epoch_call β defer function execution until a grace period π°οΈ
π LIBRARY π
Concurrency Kit (link it with libck, so like -lck bestie π
)
β¨ SYNOPSIS β¨
#include <ck_epoch.h>
typedef struct ck_epoch_entry ck_epoch_entry_t;
typedef void ck_epoch_cb_t(ck_epoch_entry_t *);
void
ck_epoch_call(ck_epoch_record_t *record, ck_epoch_entry_t *entry,
ck_epoch_cb_t *function);
like, that's the whole vibe. three args, no return, we move. π«Ά
π DESCRIPTION π
okay so the tea: ck_epoch_call(3) will defer the execution of the function pointed to by function until a grace period has been detected in epoch. yes literally, it's giving "not right now, later, when it's safe."
the function gets handed the pointer you specified with entry β that's its little gift bag π
and when does it actually run? at some time in the future, via calls to ck_epoch_reclaim(3), ck_epoch_barrier(3) or ck_epoch_poll(3). so like, you don't call it, those do. iykyk. π
π₯ EXAMPLE π₯
here's the whole thing, verbatim, because I am NOT about to mess with code that works:
#include <ck_epoch.h>
#include <ck_stack.h>
#include <stdlib.h>
/*
* epoch was previously initialized with ck_epoch_init.
*/
ck_epoch_t *epoch;
struct object {
int value;
ck_epoch_entry_t epoch_entry;
};
static struct object *global;
CK_EPOCH_CONTAINER(struct object, epoch_entry, object_container)
void
destroy_object(ck_epoch_entry_t *e)
{
struct object *o = object_container(e);
free(o);
return;
}
void
function(void)
{
ck_epoch_record_t *record;
struct object *n;
record = malloc(sizeof *record);
ck_epoch_register(&epoch, record, NULL);
n = malloc(sizeof *n);
if (n == NULL)
return;
n->value = 1;
/*
* We are using an epoch section here because there are multiple
* writers. It is also an option to use other forms of blocking
* write-side synchronization such as mutexes.
*/
ck_epoch_begin(record);
n = ck_pr_fas_ptr(&global, n);
ck_epoch_end(record);
/* Defer destruction of previous object. */
ck_epoch_call(record, &n->epoch_entry, destroy_object);
/* Poll epoch sub-system in non-blocking manner. */
ck_epoch_poll(record);
return;
}
see how destroy_object is the callback and &n->epoch_entry is the entry? yeah. iconic behaviour fr fr. π
π RETURN VALUES π
this function has no return value. it returns nothing. void. silent. mysterious. main character energy honestly. π
π ERRORS π
the object pointed to by record must have been previously registered via ck_epoch_register(3). like, if you didn't register it, bestie, that's on you. don't come crying to me. π
π¦ SEE ALSO π¦
ck_epoch_init(3)ck_epoch_register(3)ck_epoch_unregister(3)ck_epoch_recycle(3)ck_epoch_poll(3)ck_epoch_synchronize(3)ck_epoch_reclaim(3)ck_epoch_barrier(3)ck_epoch_begin(3)ck_epoch_end(3)
more lore available at http://concurrencykit.org/ β
and that's the page bestie!! this one came from the Concurrency Kit manual, and it's dated September 2, 2012 β yeah she's vintage, she's an elder, and she still slays. ππ§π
k byeeee, go read your grace periods. periodt. π
π¦ where this page comes from
- alpine 3.24: ck-doc 0.7.2-r1 Β· BSD-2-Clause AND Apache-2.0
- debian trixie: libck-dev 0.7.2-6 Β· BSD-2-Clause
- epel 10: ck-devel 0.7.2-1.el10_1 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 43: ck-devel 0.7.2-2.fc43 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 43: ck-devel 0.7.2-2.fc43 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 44: ck-devel 0.7.2-4.fc44 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 44: ck-devel 0.7.2-4.fc44 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- nixos 26.05: ck 0.7.2
- nixpkgs unstable: ck 0.7.2
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- ubuntu questing: libck-dev 0.7.2-5ubuntu1
- ubuntu resolute: libck-dev 0.7.2-5ubuntu2 Β· BSD-2-Clause
- ubuntu stonking: libck-dev 0.7.2-11 Β· BSD-2-Clause
- Copyright 2012-2013 Samy Al Bahra
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms