CK_RHS_FAS(3)
β¨ CK_RHS_FAS(3) β¨
okay bestie, gather round, because we're about to talk about fetch-and-store in a hash set and honestly? it's giving main character energy. this is the ck_rhs_fas page from the Concurrency Kit manual, and yes it lives in libck π¦
πΈ LIBRARY πΈ
Concurrency Kit β link it with -lck and you're sooo good π
π SYNOPSIS π
#include <ck_rhs.h>
bool
ck_rhs_fas(ck_rhs_t *hs, unsigned long hash, const void *key,
void **previous);
π DESCRIPTION π
so. ck_rhs_fas(3) does two things at once and honestly the way it does that? iconic. it fetches and it stores the key you hand it in the hash set that hs points at π₯
the key you pass in as key is expected to already have the hash value you passed as hash β and no, you can't just make that number up, bestie, it has to have been generated earlier using the CK_RHS_HASH(3) macro. iykyk β¨
if the call to ck_rhs_fas(3) goes through, then your key was successfully stored in the hash set pointed to by hs, periodt. BUT β and this is the part people miss β the key must already exist in the hash set. it gets replaced by key, and the previous value gets tucked into the void pointer that previous points at π«Ά
and if that key isn't in the hash set? the function returns false and the hash set stays exactly the way it was. no changes, no chaos, we love a clean no-op π
one more thing: this function is guaranteed to be stable with respect to memory usage. no sneaky allocations jumping out at you π
β RETURN VALUES β
- on success,
ck_rhs_fas(3)returnstrueπ - otherwise it returns
falseon failure π
π ERRORS π
behavior is undefined ifkeyorhsare uninitialized. not "a little weird", not "maybe fine" β UNDEFINED. initialize your stuff, bestie, i'm begging π§
π SEE ALSO π
ck_rhs_init(3)ck_rhs_move(3)ck_rhs_destroy(3)CK_RHS_HASH(3)ck_rhs_iterator_init(3)ck_rhs_next(3)ck_rhs_get(3)ck_rhs_put(3)ck_rhs_put_unique(3)ck_rhs_remove(3)ck_rhs_grow(3)ck_rhs_rebuild(3)ck_rhs_gc(3)ck_rhs_count(3)ck_rhs_reset(3)ck_rhs_reset_size(3)ck_rhs_stat(3)
additional info is available at http://concurrencykit.org/ π
mwah that's the whole page π this gem dropped June 20, 2013, and it ships with Concurrency Kit β so go forth, replace some keys, and stay stable with respect to memory usage πΈβ¨π
π¦ where this page comes from
- alpine 3.24: ck-doc 0.7.2-r1 Β· BSD-2-Clause AND Apache-2.0
- debian bookworm: libck-dev 0.7.1-10 Β· BSD-2-Clause
- 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
- epel 9: ck-devel 0.7.0-10.el9 Β· BSD
- 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 jammy: libck-dev 0.7.1-6ubuntu2 Β· BSD-2-Clause
- ubuntu noble: libck-dev 0.7.1-13build1 Β· 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 2013 Samy Al Bahra
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms