Changeset b9cb911 in mainline for kernel/generic/include/adt/cht.h


Ignore:
Timestamp:
2012-08-20T18:40:19Z (13 years ago)
Author:
Adam Hraska <adam.hraska+hos@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7cfe5c0
Parents:
85d31de9
Message:

cht: API comments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/adt/cht.h

    r85d31de9 rb9cb911  
    4949         *
    5050         * 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.
    5254         */
    5355        union {
     
    6163/** Set of operations for a concurrent hash table. */
    6264typedef 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         */
    6370        size_t (*hash)(const cht_link_t *item);
     71        /** Returns the hash value of the key used to search for entries. */
    6472        size_t (*key_hash)(void *key);
     73        /** Returns true if the two items store equal search keys. */
    6574        bool (*equal)(const cht_link_t *item1, const cht_link_t *item2);
     75        /** Returns true if the item contains an equal search key. */
    6676        bool (*key_equal)(void *key, const cht_link_t *item);
     77        /** Invoked to free a removed item once all references to it are dropped. */
    6778        void (*remove_callback)(cht_link_t *item);
    6879} cht_ops_t;
    6980
    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 */
    7186typedef struct cht_buckets {
     87        /** The number of buckets is 2^order. */
    7288        size_t order;
     89        /** Array of single linked list bucket heads along with any marks. */
    7390        cht_ptr_t head[1];
    7491} cht_buckets_t;
     
    7693/** Concurrent hash table structure. */
    7794typedef struct {
     95        /** Item specific operations. */
    7896        cht_ops_t *op;
    7997       
     98        /** Buckets currently in use. */
    8099        cht_buckets_t *b;
     100        /** Resized table buckets that will replace b once resize is complete. */
    81101        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         */
    82109        size_t invalid_hash;
    83110
     111        /** Minimum number of buckets is 2^min_order. */
    84112        size_t min_order;
     113        /** Maximum number of items per bucket before the table grows. */
    85114        size_t max_load;
     115        /** Table is resized in the background in a work queue. */
    86116        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         */
    87121        atomic_t resize_reqs;
    88122       
     123        /** Number of items in the table that have not been logically deleted. */
    89124        atomic_t item_cnt;
    90125} cht_t;
Note: See TracChangeset for help on using the changeset viewer.