Changeset b9cb911 in mainline for kernel/generic/include/adt/cht.h
- Timestamp:
- 2012-08-20T18:40:19Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7cfe5c0
- Parents:
- 85d31de9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/adt/cht.h
r85d31de9 rb9cb911 49 49 * 50 50 * The function pointer (rcu_link.func) is used to store the item's 51 * memoized hash. 51 * mixed memoized hash. If in use by RCU (ie waiting for deferred 52 * destruction) the hash will contain the value of 53 * cht_t.op->remove_callback. 52 54 */ 53 55 union { … … 61 63 /** Set of operations for a concurrent hash table. */ 62 64 typedef struct cht_ops { 65 /** Returns the hash of the item. 66 * 67 * Applicable also to items that were logically deleted from the table 68 * but have yet to be physically removed by means of remove_callback(). 69 */ 63 70 size_t (*hash)(const cht_link_t *item); 71 /** Returns the hash value of the key used to search for entries. */ 64 72 size_t (*key_hash)(void *key); 73 /** Returns true if the two items store equal search keys. */ 65 74 bool (*equal)(const cht_link_t *item1, const cht_link_t *item2); 75 /** Returns true if the item contains an equal search key. */ 66 76 bool (*key_equal)(void *key, const cht_link_t *item); 77 /** Invoked to free a removed item once all references to it are dropped. */ 67 78 void (*remove_callback)(cht_link_t *item); 68 79 } cht_ops_t; 69 80 70 81 /** Groups hash table buckets with their count. 82 * 83 * It allows both the number of buckets as well as the bucket array 84 * to be swapped atomically when resing the table. 85 */ 71 86 typedef struct cht_buckets { 87 /** The number of buckets is 2^order. */ 72 88 size_t order; 89 /** Array of single linked list bucket heads along with any marks. */ 73 90 cht_ptr_t head[1]; 74 91 } cht_buckets_t; … … 76 93 /** Concurrent hash table structure. */ 77 94 typedef struct { 95 /** Item specific operations. */ 78 96 cht_ops_t *op; 79 97 98 /** Buckets currently in use. */ 80 99 cht_buckets_t *b; 100 /** Resized table buckets that will replace b once resize is complete. */ 81 101 cht_buckets_t *new_b; 102 /** Invalid memoized hash value. 103 * 104 * If cht_link.hash contains this value the item had been logically 105 * removed and is waiting to be freed. Such hashes (and the associated 106 * items) are disregarded and skipped or the actual hash must be 107 * determined via op->hash(). 108 */ 82 109 size_t invalid_hash; 83 110 111 /** Minimum number of buckets is 2^min_order. */ 84 112 size_t min_order; 113 /** Maximum number of items per bucket before the table grows. */ 85 114 size_t max_load; 115 /** Table is resized in the background in a work queue. */ 86 116 work_t resize_work; 117 /** If positive the table should grow or shrink. 118 * 119 * If not 0 resize work had already been posted to the system work queue. 120 */ 87 121 atomic_t resize_reqs; 88 122 123 /** Number of items in the table that have not been logically deleted. */ 89 124 atomic_t item_cnt; 90 125 } cht_t;
Note:
See TracChangeset
for help on using the changeset viewer.