---
name: "ck_ht_put_spmc"
section: "3"
platform: "linux"
package: "libck-dev"
version: "0.7.2-6"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/ck_ht_put_spmc"
---

# ck\_ht\_put\_spmc(3)

store unique key-value pair into hash table

## NAME

**ck\_ht\_put\_spmc** – store unique key-value pair into hash table

## LIBRARY

Concurrency Kit (libck, -lck)

## SYNOPSIS

**#include \<ck\_ht.h\>**

*bool*\

**ck\_ht\_put\_spmc**(*ck\_ht\_t \*ht*, *ck\_ht\_hash\_t h*, *ck\_ht\_entry\_t \*entry*);

## DESCRIPTION

The **ck\_ht\_put\_spmc**() function will store the key-value pair specified in the *entry* argument in the hash table pointed to by the *ht* argument. The key specified in *entry* is expected to have the hash value specified by the *h* argument.

If *ht* was created with CK\_HT\_MODE\_BYTESTRING then *entry* must have been initialized with the [ck\_ht\_entry\_set(3)](/ck_ht_entry_set/3.md) function. If *ht* was created with CK\_HT\_MODE\_DIRECT then *entry* must have been initialized with the [ck\_ht\_entry\_set\_direct(3)](/ck_ht_entry_set_direct/3.md) function.

It is expected that *h* was initialized with [ck\_ht\_hash(3)](/ck_ht_hash/3.md) if *ht* was created with CK\_HT\_MODE\_BYTESTRING. If *ht* was initialized with CK\_HT\_MODE\_DIRECT then it is expected that *h* was initialized with the [ck\_ht\_hash\_direct(3)](/ck_ht_hash_direct/3.md) 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 will fail if the key specified in *entry* already exists with-in the hash table. Replacement semantics are provided by the [ck\_ht\_set\_spmc(3)](/ck_ht_set_spmc/3.md) function.

This function is safe to call in the presence of concurrent [ck\_ht\_get\_spmc(3)](/ck_ht_get_spmc/3.md) operations.

## RETURN VALUES

Upon successful completion **ck\_ht\_put\_spmc**() returns true and otherwise returns false on failure.

## ERRORS

Behavior is undefined if *entry* or *ht* are uninitialized. The function will return false if the hash table required to be grown but failed while attempting to grow or if the key specified in *entry* was already present in the hash table.

## SEE ALSO

[ck\_ht\_stat(3)](/ck_ht_stat/3.md), [ck\_ht\_init(3)](/ck_ht_init/3.md), [ck\_ht\_destroy(3)](/ck_ht_destroy/3.md), [ck\_ht\_hash(3)](/ck_ht_hash/3.md), [ck\_ht\_hash\_direct(3)](/ck_ht_hash_direct/3.md), [ck\_ht\_set\_spmc(3)](/ck_ht_set_spmc/3.md), [ck\_ht\_gc(3)](/ck_ht_gc/3.md), [ck\_ht\_get\_spmc(3)](/ck_ht_get_spmc/3.md), [ck\_ht\_grow\_spmc(3)](/ck_ht_grow_spmc/3.md), [ck\_ht\_remove\_spmc(3)](/ck_ht_remove_spmc/3.md), [ck\_ht\_reset\_spmc(3)](/ck_ht_reset_spmc/3.md), [ck\_ht\_reset\_size\_spmc(3)](/ck_ht_reset_size_spmc/3.md), [ck\_ht\_count(3)](/ck_ht_count/3.md), [ck\_ht\_entry\_empty(3)](/ck_ht_entry_empty/3.md), [ck\_ht\_entry\_key\_set(3)](/ck_ht_entry_key_set/3.md), [ck\_ht\_entry\_key\_set\_direct(3)](/ck_ht_entry_key_set_direct/3.md), [ck\_ht\_entry\_key(3)](/ck_ht_entry_key/3.md), [ck\_ht\_entry\_key\_length(3)](/ck_ht_entry_key_length/3.md), [ck\_ht\_entry\_value(3)](/ck_ht_entry_value/3.md), [ck\_ht\_entry\_set(3)](/ck_ht_entry_set/3.md), [ck\_ht\_entry\_set\_direct(3)](/ck_ht_entry_set_direct/3.md), [ck\_ht\_entry\_key\_direct(3)](/ck_ht_entry_key_direct/3.md), [ck\_ht\_entry\_value\_direct(3)](/ck_ht_entry_value_direct/3.md), [ck\_ht\_iterator\_init(3)](/ck_ht_iterator_init/3.md), [ck\_ht\_next(3)](/ck_ht_next/3.md)

Additional information available at http://concurrencykit.org/
