CK_EPOCH_SYNCHRONIZE(3)
π CK_EPOCH_SYNCHRONIZE(3) π
okay bestie, so this one lives in the Concurrency Kit library, aka libck, and you link it with -lck. It's a section 3 manpage, and it's literally the "wait for a grace period" girlie. Let's get into it π¦
β¨ NAME β¨
ck_epoch_synchronize β block until a grace period has been detected π«Ά
π LIBRARY π
Concurrency Kit (that's libck, and you pass -lck) π
πΈ SYNOPSIS πΈ
#include <ck_epoch.h>
void
ck_epoch_synchronize(ck_epoch_record_t *record);
π« DESCRIPTION π«
So ck_epoch_synchronize(3) will block the caller until a grace period has been detected, following the whole semantics of epoch reclamation. No cap. It just sits there, patiently, until the coast is clear. β³
π¨ Important bestie: it is NOT safe to call this function on a record that is in an active section. Like, do not do that. That's a vibe check you will fail. π
Any objects that need safe memory reclamation and are logically deleted are safe for physical deletion right after you call ck_epoch_synchronize(3). Slay. β¨
But listen β if you need all callbacks to be dispatched, the move is to use ck_epoch_barrier(3) instead, OR you follow up your ck_epoch_synchronize(3) call with ck_epoch_reclaim(3). Either way, get those callbacks their moment. π
π EXAMPLE π
okay here's the whole thing, and it's giving main character energy fr fr:
#include <ck_epoch.h>
#include <ck_stack.h>
#include <stdlib.h>
/*
* epoch was previously initialized with ck_epoch_init.
* stack was previously initialized with ck_stack_init.
*/
ck_epoch_t *epoch;
ck_stack_t *stack;
void
function(void)
{
ck_epoch_record_t *record;
ck_stack_entry_t *s;
record = malloc(sizeof *record);
ck_epoch_register(&epoch, record, NULL);
/*
* We are using an epoch section here to guarantee no
* nodes in the stack are deleted while we are dereferencing
* them. This is needed here because there are multiple writers.
* If there was only one thread popping from the this stack,
* then there is no need to ck_epoch_begin/ck_epoch_end.
*/
ck_epoch_begin(record);
/* Logically delete an object. */
s = ck_stack_pop_upmc(stack);
ck_epoch_end(record);
/*
* Wait until no threads could possibly have a reference to the
* object we just popped (assume all threads are simply executing
* ck_stack_pop_upmc).
*/
ck_epoch_synchronize(record);
/* It is now safe to physically delete the object. */
free(s);
return;
}
see how we ck_epoch_begin(record) before popping so nobody deletes nodes while we're dereferencing them? that's the whole point, and it matters because there are multiple writers. if only one thread was popping off this stack, you wouldn't even need ck_epoch_begin/ck_epoch_end. iykyk π
π₯ RETURN VALUES π₯
This function has no return value. Nothing. Nada. It just vibes and blocks. π
π ERRORS π
The object pointed to by record must have been previously registered via ck_epoch_register(3). That's the whole deal β if it wasn't registered, that's on you bestie. π«
π SEE ALSO π
ck_epoch_init(3)ck_epoch_register(3)ck_epoch_unregister(3)ck_epoch_recycle(3)ck_epoch_poll(3)ck_epoch_reclaim(3)ck_epoch_barrier(3)ck_epoch_call(3)ck_epoch_begin(3)ck_epoch_end(3)
Additional information available at http://concurrencykit.org/ β go be nosy, it's worth it π¦
okay that's the whole page bestie!! this one was dated September 2, 2012, and it's part of the CK_EPOCH_SYNCHRONIZE(3) manpage from Concurrency Kit. go forth, synchronize your grace periods, and stay safe out there πβ¨π 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