CK_EPOCH_RECYCLE(3)
π CK_EPOCH_RECYCLE(3) π
okay bestie, welcome to the Concurrency Kit manual, section 3, page ck_epoch_recycle β¨ this one lives in libck (that's the library you link with -lck, mwah π«Ά)
πΈ NAME πΈ
ck_epoch_recycle β hand back an epoch record that's just sitting there unused so you can use it, no cap π
π LIBRARY π
Concurrency Kit (libck, link it with -lck) π§
β¨ SYNOPSIS β¨
#include <ck_epoch.h>
ck_epoch_record_t *
ck_epoch_recycle(ck_epoch_t *epoch);
like. look at that. one include, one function call. iconic behavior honestly π
π DESCRIPTION π
so, the ck_epoch_recycle(3) function attempts to return an unused epoch record object for the caller to use π¦
and where do these free little records come from? they were associated with previous calls to the ck_epoch_unregister(3) function β so basically when someone dipped out of the epoch system, their record got parked, and this function is you pulling up like "hey is anyone sitting here π" π
π EXAMPLE π
here's the whole vibe, bestie:
#include <ck_epoch.h>
#include <stdlib.h>
/*
* epoch was previously initialized with ck_epoch_init.
*/
ck_epoch_t *epoch;
void
function(void)
{
ck_epoch_record_t *record;
record = ck_epoch_recycle(&epoch);
if (record == NULL) {
record = malloc(sizeof *record);
if (record == NULL)
return;
ck_epoch_register(&epoch, record, NULL);
}
/*
* After we are done, we will unregister the record so it
* can be used by other new participants in the epoch system
* provided by the object pointed to by "epoch".
*/
ck_epoch_unregister(&epoch, record);
return;
}
the way this works: you try to recycle, and if you get NULL back (π) you just malloc your own and ck_epoch_register(&epoch, record, NULL) it into existence. then when you're done you ck_epoch_unregister(&epoch, record) so somebody else can snatch it up later. the circle of life fr fr π
π«Ά RETURN VALUES π«Ά
this function returns a pointer to a ck_epoch_record_t object β
but if no unused record was found to be associated with the object pointed to by epoch? then it just returns NULL and you're on your own bestie π
π ERRORS π
Behavior is undefined if the object pointed to by epoch is not a valid epoch object. not "a little weird", not "probably fine" β undefined. do not pass it garbage, i am begging π
π¦ SEE ALSO π¦
ck_epoch_init(3)ck_epoch_register(3)ck_epoch_unregister(3)ck_epoch_poll(3)ck_epoch_synchronize(3)ck_epoch_reclaim(3)ck_epoch_barrier(3)ck_epoch_call(3)ck_epoch_begin(3)ck_epoch_end(3)
more lore available at http://concurrencykit.org/ π
okay that's the whole page, you ate it, go recycle some records π this one was dated September 2, 2012 and filed under CK_EPOCH_RECYCLE(3) β mwah, ily, bye ππΈβ¨
π¦ 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