]> git.proxmox.com Git - mirror_ovs.git/blob - lib/ccmap.h
ovsdb-idl: Remove prototype for function that is not defined or used.
[mirror_ovs.git] / lib / ccmap.h
1 /*
2 * Copyright (c) 2014, 2016 Nicira, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef CCMAP_H
18 #define CCMAP_H 1
19
20 #include <stdbool.h>
21 #include <stdint.h>
22 #include "ovs-rcu.h"
23 #include "util.h"
24
25 /* Concurrent hash map for numerical counts of given hash values.
26 * ==============================================================
27 *
28 * A single-writer, multiple-reader count hash table that efficiently supports
29 * duplicates.
30 *
31 *
32 * Thread-safety
33 * =============
34 *
35 * The general rules are:
36 *
37 * - Only a single thread may safely call into ccmap_inc(),
38 * or ccmap_dec() at any given time.
39 *
40 * - Any number of threads may use functions and macros that search
41 * a given ccmap, even in parallel with other threads
42 * calling ccmap_inc() or ccmap_dec().
43 */
44
45 /* Concurrent hash map. */
46 struct ccmap {
47 OVSRCU_TYPE(struct ccmap_impl *) impl;
48 };
49
50 /* Initialization. */
51 void ccmap_init(struct ccmap *);
52 void ccmap_destroy(struct ccmap *);
53
54 /* Count. */
55 size_t ccmap_count(const struct ccmap *);
56 bool ccmap_is_empty(const struct ccmap *);
57
58 /* Insertion and deletion. Return the current count after the operation. */
59 uint32_t ccmap_inc(struct ccmap *, uint32_t hash);
60 uint32_t ccmap_dec(struct ccmap *, uint32_t hash);
61
62 uint32_t ccmap_find(const struct ccmap *, uint32_t hash);
63
64 #endif /* ccmap.h */