]>
git.proxmox.com Git - mirror_ovs.git/blob - lib/ccmap.h
2 * Copyright (c) 2014, 2016 Nicira, Inc.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
25 /* Concurrent hash map for numerical counts of given hash values.
26 * ==============================================================
28 * A single-writer, multiple-reader count hash table that efficiently supports
35 * The general rules are:
37 * - Only a single thread may safely call into ccmap_inc(),
38 * or ccmap_dec() at any given time.
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().
45 /* Concurrent hash map. */
47 OVSRCU_TYPE(struct ccmap_impl
*) impl
;
51 void ccmap_init(struct ccmap
*);
52 void ccmap_destroy(struct ccmap
*);
55 size_t ccmap_count(const struct ccmap
*);
56 bool ccmap_is_empty(const struct ccmap
*);
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
);
62 uint32_t ccmap_find(const struct ccmap
*, uint32_t hash
);