CK_HT_GET_SPMC(3)
π CK_HT_GET_SPMC β the manual, but make it cute π
okay bestie, welcome to ck_ht_get_spmc(3), a page from the Concurrency Kit manual β that's libck, and you link it with -lck. she's a little lookup queen and she's about to find your key in a hash table, no cap. π¦
β¨ NAME β¨
ck_ht_get_spmc β load a key-value pair from a hash table πΈ
π LIBRARY π
Concurrency Kit, aka libck, and you link her with -lck. periodt. π
π SYNOPSIS π
#include <ck_ht.h>
bool
ck_ht_get_spmc(ck_ht_t *ht, ck_ht_hash_t h, ck_ht_entry_t *entry);
π«Ά DESCRIPTION π«Ά
so basically, ck_ht_get_spmc() will return the value associated with the key specified in the entry argument, inside the hash table pointed to by the ht argument. and the key chillin' in entry? she's expected to have the hash value specified by the h argument. like, they gotta match, bestie. π
now, this part matters, so listen up:
- if
htwas created withCK_HT_MODE_BYTESTRING, thenentrymust have been initialized with theck_ht_entry_set_key(3)orck_ht_entry_set(3)functions. - if
htwas created withCK_HT_MODE_DIRECT, thenentrymust have been initialized with theck_ht_entry_key_set_direct(3)orck_ht_entry_set_direct(3)functions.
and for the hash:
- it's expected that
hwas initialized withck_ht_hash(3)ifhtwas created withCK_HT_MODE_BYTESTRING. - if
htwas initialized withCK_HT_MODE_DIRECT, then it's expected thathwas initialized with theck_ht_hash_direct(3)function.
okay so what actually happens: if the call to ck_ht_get_spmc() was successful, then the key-value pair in entry was successfully found in the hash table pointed to by h β and it will fail if the key specified in entry does not exist in the hash table. if it's successful, entry will contain the key-value pair found in the hash table pointed to by the ht argument. iconic behavior honestly. π
now how do you get your lil data back out? depends on the mode:
- if
htwas initialized withCK_HT_MODE_BYTESTRING, then the key/value pair inentrymay be extracted using theck_ht_entry_key(3)andck_ht_entry_value(3)functions. the length of the key may be extracted using theck_ht_entry_key_length(3)function. π - if
htwas initialized withCK_HT_MODE_DIRECT, then the key/value pair inentrymay be extracted using theck_ht_entry_key_direct(3)andck_ht_entry_value_direct(3)functions.
and the best part?? this function is safe to call in the presence of a concurrent writer. she's built different fr fr. π₯
β RETURN VALUES β
upon successful completion, ck_ht_get_spmc() returns true. and if it's successful, entry will contain the key/value pair as found in the hash table. π
otherwise? the function returns false on failure. that's it, that's the whole vibe check. π
π ERRORS π
behavior is undefined ifentryorhtare uninitialized. like, do not do that, bestie, that's the scary part. π
the function will return false if the key as specified in entry was not found in the hash table. (which is honestly the gentlest possible outcome here, so count your blessings π)
π SEE ALSO π
ck_ht_stat(3), ck_ht_init(3), ck_ht_destroy(3), ck_ht_hash(3), ck_ht_hash_direct(3), ck_ht_set_spmc(3), ck_ht_put_spmc(3), ck_ht_gc(3), ck_ht_grow_spmc(3), ck_ht_remove_spmc(3), ck_ht_reset_spmc(3), ck_ht_reset_size_spmc(3), ck_ht_count(3), ck_ht_entry_empty(3), ck_ht_entry_key_set(3), ck_ht_entry_key_set_direct(3), ck_ht_entry_key(3), ck_ht_entry_key_length(3), ck_ht_entry_value(3), ck_ht_entry_set(3), ck_ht_entry_set_direct(3), ck_ht_entry_key_direct(3), ck_ht_entry_value_direct(3), ck_ht_iterator_init(3), ck_ht_next(3)
additional info is available at http://concurrencykit.org/ π§
and that's the whole page, babe. this one's dated March 29, 2012, and it lives under CK_HT_GET_SPMC(3). go forth and look up your keys, you main character. π
β¨π«Ά
π¦ 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 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