| 1 |
.\" |
| 2 |
.\" Copyright 2012-2013 Samy Al Bahra. |
| 3 |
.\" All rights reserved. |
| 4 |
.\" |
| 5 |
.\" Redistribution and use in source and binary forms, with or without |
| 6 |
.\" modification, are permitted provided that the following conditions |
| 7 |
.\" are met: |
| 8 |
.\" 1. Redistributions of source code must retain the above copyright |
| 9 |
.\" notice, this list of conditions and the following disclaimer. |
| 10 |
.\" 2. Redistributions in binary form must reproduce the above copyright |
| 11 |
.\" notice, this list of conditions and the following disclaimer in the |
| 12 |
.\" documentation and/or other materials provided with the distribution. |
| 13 |
.\" |
| 14 |
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 15 |
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 |
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 17 |
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 18 |
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 19 |
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 20 |
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 21 |
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 22 |
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 23 |
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 24 |
.\" SUCH DAMAGE. |
| 25 |
.\" |
| 26 |
.\" |
| 27 |
.Dd March 29, 2012 |
| 28 |
.Dt CK_HT_GET_SPMC 3 |
| 29 |
.Sh NAME |
| 30 |
.Nm ck_ht_get_spmc |
| 31 |
.Nd load a key-value pair from a hash table |
| 32 |
.Sh LIBRARY |
| 33 |
Concurrency Kit (libck, \-lck) |
| 34 |
.Sh SYNOPSIS |
| 35 |
.In ck_ht.h |
| 36 |
.Ft bool |
| 37 |
.Fn ck_ht_get_spmc "ck_ht_t *ht" "ck_ht_hash_t h" "ck_ht_entry_t *entry" |
| 38 |
.Sh DESCRIPTION |
| 39 |
The |
| 40 |
.Fn ck_ht_get_spmc |
| 41 |
function will return the value associated with the key specified in the |
| 42 |
.Fa entry |
| 43 |
argument in the hash table pointed to by the |
| 44 |
.Fa ht |
| 45 |
argument. The key specified in |
| 46 |
.Fa entry |
| 47 |
is expected to have the hash value specified by the |
| 48 |
.Fa h |
| 49 |
argument. |
| 50 |
.Pp |
| 51 |
If |
| 52 |
.Fa ht |
| 53 |
was created with CK_HT_MODE_BYTESTRING then |
| 54 |
.Fa entry |
| 55 |
must have been initialized with the |
| 56 |
.Xr ck_ht_entry_set_key 3 |
| 57 |
or |
| 58 |
.Xr ck_ht_entry_set 3 |
| 59 |
functions. If |
| 60 |
.Fa ht |
| 61 |
was created with CK_HT_MODE_DIRECT then |
| 62 |
.Fa entry |
| 63 |
must have been initialized with the |
| 64 |
.Xr ck_ht_entry_key_set_direct 3 |
| 65 |
or |
| 66 |
.Xr ck_ht_entry_set_direct 3 |
| 67 |
functions. |
| 68 |
.Pp |
| 69 |
It is expected that |
| 70 |
.Fa h |
| 71 |
was initialized with |
| 72 |
.Xr ck_ht_hash 3 |
| 73 |
if |
| 74 |
.Fa ht |
| 75 |
was created with CK_HT_MODE_BYTESTRING. If |
| 76 |
.Fa ht |
| 77 |
was initialized with CK_HT_MODE_DIRECT then it is |
| 78 |
expected that |
| 79 |
.Fa h |
| 80 |
was initialized with the |
| 81 |
.Xr ck_ht_hash_direct 3 |
| 82 |
function. |
| 83 |
.Pp |
| 84 |
If the call to |
| 85 |
.Fn ck_ht_get_spmc |
| 86 |
was successful then the key-value pair in |
| 87 |
.Fa entry |
| 88 |
was successfully found in the hash table pointed |
| 89 |
to by |
| 90 |
.Fa h |
| 91 |
and will fail if the key specified in |
| 92 |
.Fa entry |
| 93 |
does not exist in the hash table. If successful |
| 94 |
.Fa entry |
| 95 |
will contain the key-value pair found in the hash table |
| 96 |
pointed to by the |
| 97 |
.Fa ht |
| 98 |
argument. |
| 99 |
.Pp |
| 100 |
If |
| 101 |
.Fa ht |
| 102 |
was initialized with CK_HT_MODE_BYTESTRING then |
| 103 |
the key/value pair in |
| 104 |
.Fa entry |
| 105 |
may be extracted using the |
| 106 |
.Xr ck_ht_entry_key 3 |
| 107 |
and |
| 108 |
.Xr ck_ht_entry_value 3 |
| 109 |
functions. The length of the key may be extracted |
| 110 |
using the |
| 111 |
.Xr ck_ht_entry_key_length 3 |
| 112 |
function. |
| 113 |
.Pp |
| 114 |
If |
| 115 |
.Fa ht |
| 116 |
was initialized with CK_HT_MODE_DIRECT then the |
| 117 |
key/value pair in |
| 118 |
.Fa entry |
| 119 |
may be extracted using the |
| 120 |
.Xr ck_ht_entry_key_direct 3 |
| 121 |
and |
| 122 |
.Xr ck_ht_entry_value_direct 3 |
| 123 |
functions. |
| 124 |
.Pp |
| 125 |
This function is safe to call in the presence of a concurrent writer. |
| 126 |
.Sh RETURN VALUES |
| 127 |
Upon successful completion |
| 128 |
.Fn ck_ht_get_spmc |
| 129 |
returns |
| 130 |
.Dv true. |
| 131 |
If successful, |
| 132 |
.Fa entry |
| 133 |
will contain the key/value pair as found |
| 134 |
in the hash table. |
| 135 |
Otherwise the function returns |
| 136 |
.Dv false |
| 137 |
on failure. |
| 138 |
.Sh ERRORS |
| 139 |
.Bl -tag -width Er |
| 140 |
Behavior is undefined if |
| 141 |
.Fa entry |
| 142 |
or |
| 143 |
.Fa ht |
| 144 |
are uninitialized. The function will return |
| 145 |
.Dv false |
| 146 |
if the key as specified in |
| 147 |
.Fa entry |
| 148 |
was not found in the hash table. |
| 149 |
.El |
| 150 |
.Sh SEE ALSO |
| 151 |
.Xr ck_ht_stat 3 , |
| 152 |
.Xr ck_ht_init 3 , |
| 153 |
.Xr ck_ht_destroy 3 , |
| 154 |
.Xr ck_ht_hash 3 , |
| 155 |
.Xr ck_ht_hash_direct 3 , |
| 156 |
.Xr ck_ht_set_spmc 3 , |
| 157 |
.Xr ck_ht_put_spmc 3 , |
| 158 |
.Xr ck_ht_gc 3 , |
| 159 |
.Xr ck_ht_grow_spmc 3 , |
| 160 |
.Xr ck_ht_remove_spmc 3 , |
| 161 |
.Xr ck_ht_reset_spmc 3 , |
| 162 |
.Xr ck_ht_reset_size_spmc 3 , |
| 163 |
.Xr ck_ht_count 3 , |
| 164 |
.Xr ck_ht_entry_empty 3 , |
| 165 |
.Xr ck_ht_entry_key_set 3 , |
| 166 |
.Xr ck_ht_entry_key_set_direct 3 , |
| 167 |
.Xr ck_ht_entry_key 3 , |
| 168 |
.Xr ck_ht_entry_key_length 3 , |
| 169 |
.Xr ck_ht_entry_value 3 , |
| 170 |
.Xr ck_ht_entry_set 3 , |
| 171 |
.Xr ck_ht_entry_set_direct 3 , |
| 172 |
.Xr ck_ht_entry_key_direct 3 , |
| 173 |
.Xr ck_ht_entry_value_direct 3 , |
| 174 |
.Xr ck_ht_iterator_init 3 , |
| 175 |
.Xr ck_ht_next 3 |
| 176 |
.Pp |
| 177 |
Additional information available at http://concurrencykit.org/ |