ccommon icon indicating copy to clipboard operation
ccommon copied to clipboard

generic hashtable template with optional locking mask

Open thinkingfish opened this issue 7 years ago • 0 comments

There are 4 hashtables in Pelikan now, each only very slightly different. In general if we can create a hashtable template with the following components pluggable, we can serve them all. This is likely gonna require more macros, but we do use cc_queue.h anyway.

  • type of hash node
  • type of "key" to build hash from
  • hash function used (against key)
  • comparison function on "key"

Additionally, it'd be nice to provide built-in per-entry locking support. This can be achieved by having an bit-mask for all entries, and set the corresponding bit to true when an entry is being accessed. The granularity of the lock can be adjusted by changing the mapping between bit-mask and hash entry (e.g. 2**n entries mapping to the same bit in mask, n being configurable).

Of course, if only we use a language that has proper templating...

thinkingfish avatar Apr 04 '17 16:04 thinkingfish