CK_HT_PUT_SPMC(3)
π CK_HT_PUT_SPMC π
okay so bestie, welcome to ck_ht_put_spmc(3) β yes that's the manual page name, and yes it lives in section 3 of the manual, we love a section 3 moment π«Ά
This one's part of Concurrency Kit, aka libck, and you link it with -lck. Iconic library, no cap. β¨
πΈ SYNOPSIS πΈ
#include <ck_ht.h>
bool
ck_ht_put_spmc(ck_ht_t *ht, ck_ht_hash_t h, ck_ht_entry_t *entry);
look at her. three little args. so demure. π
β¨ DESCRIPTION β¨
so what does ck_ht_put_spmc() actually do? she stores the key-value pair you specified in the entry argument into the hash table pointed to by the ht argument. that's the whole gig. π
and here's the thing β the key you put in entry is expected to have the hash value specified by the h argument. like, you already did that part, girl. she's not doing it for you.
now, the mode check, because it matters:
- if ht was created with
CK_HT_MODE_BYTESTRING, then entry must have been initialized with theck_ht_entry_set(3)function. - if ht was created with
CK_HT_MODE_DIRECT, then entry must have been initialized with theck_ht_entry_set_direct(3)function.
and same energy for the hash value h:
- it's expected that h was initialized with
ck_ht_hash(3)if ht was created withCK_HT_MODE_BYTESTRING. - if ht was initialized with
CK_HT_MODE_DIRECT, then it's expected that h was initialized with theck_ht_hash_direct(3)function.
if the call to ck_ht_put_spmc() was successful, then the key-value pair in entry was successfully stored in the hash table pointed to by ht β and it will fail if the key specified in entry already exists with-in the hash table. π yes, this one is strictly insert-only, she does NOT overwrite.
so if you wanted replace-y, swap-her-out energy? that's not this function. replacement semantics are provided by the ck_ht_set_spmc(3) function. go ask her. π
one more thing and it's a big one: this function is safe to call in the presence of concurrent ck_ht_get_spmc(3) operations. main character energy, honestly. π₯
π RETURN VALUES π
upon successful completion, ck_ht_put_spmc() returns true. otherwise she returns false on failure. binary. simple. slay. β¨
π ERRORS π
okay bestie, listen up, this part is the serious part:
behavior is undefined if entry or ht are uninitialized. not "kinda weird", not "returns garbage" β undefined. we do not play with that. π¨
the function will return false if:
- the hash table required to be grown but failed while attempting to grow, or
- the key specified in entry was already present in the hash table.
that's it, that's the list. π
π SEE ALSO π
the whole friend group, fr fr:
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_gc(3), ck_ht_get_spmc(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 information available at http://concurrencykit.org/ π
and that's the page!! mwah π this little beauty is from March 29, 2012 β yeah she's an elder but she ate and left no crumbs β and it's the CK_HT_PUT_SPMC(3) page out of the Concurrency Kit source, version-wise. go forth and insert, bestie. ππ¦πΈ
π¦ 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