diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-17 16:55:25 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-17 17:44:48 -0800 |
| commit | eb3b131db73610274a41f04d8fd6b7cf879cc016 (patch) | |
| tree | 957ed45ef5fd8919bb2a65f9827b1bc8695b6f6c /src/core/idhash.h | |
| parent | ac9236de0bc9ed3000947ef6eeeae1cd874d3071 (diff) | |
| download | nng-eb3b131db73610274a41f04d8fd6b7cf879cc016.tar.gz nng-eb3b131db73610274a41f04d8fd6b7cf879cc016.tar.bz2 nng-eb3b131db73610274a41f04d8fd6b7cf879cc016.zip | |
Added dynamic ID generation & management for idhash tables.
This will allow us to use idhash tables to manage id handles a bit more
flexibly. For example, sockets, pipe IDs, etc. can all be generated, and
we can use hash tables to ensure that values do not collide.
Diffstat (limited to 'src/core/idhash.h')
| -rw-r--r-- | src/core/idhash.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/core/idhash.h b/src/core/idhash.h index bfd0f595..e8876ad5 100644 --- a/src/core/idhash.h +++ b/src/core/idhash.h @@ -20,8 +20,7 @@ // we use a better probe (taken from Python) to avoid hitting the same // positions. Our hash algorithm is just the low order bits, and we // use table sizes that are powers of two. Note that hash items -// must be non-NULL. The caller is responsible for providing any -// locking required. +// must be non-NULL. The table is locked. typedef struct nni_idhash nni_idhash; @@ -30,12 +29,16 @@ typedef struct nni_idhash nni_idhash; // process and return that return value. The function takes the generic // opaque value for the walk as its first argument, and the next two // arguments are the hash key and the opaque value stored with it. +// Note that the walkfn must not attempt to change the hash table. +// The user must provide any locking needed. typedef int (*nni_idhash_walkfn)(void *, uint32_t, void *); extern int nni_idhash_create(nni_idhash **); +extern void nni_idhash_set_limits(nni_idhash *, uint32_t, uint32_t, uint32_t); extern void nni_idhash_destroy(nni_idhash *); extern int nni_idhash_find(nni_idhash *, uint32_t, void **); extern int nni_idhash_remove(nni_idhash *, uint32_t); extern int nni_idhash_insert(nni_idhash *, uint32_t, void *); +extern int nni_idhash_alloc(nni_idhash *, uint32_t *, void *); extern int nni_idhash_count(nni_idhash *, uint32_t *); extern int nni_idhash_walk(nni_idhash *, nni_idhash_walkfn, void *); |
