|
trafilo 0.1.0
Streaming event-handler framework in C
|
Functions | |
| hashmap_t * | hashmap_create (size_t num_buckets) |
| Create a hashmap. | |
| static uint64_t | fnv1a (const char *key) |
| FNV1A Hashing function. | |
| static size_t | bucket_index (const hashmap_t *m, const char *key) |
| Bucket Indexing. | |
| static bucket_node * | bucket_create (const char *key) |
| bucket_node * | hashmap_find_or_create (hashmap_t *hashmap, const char *key) |
| Find bucket for key; create if absent. Returns with bucket->bucket_lock LOCKED. | |
| void | hashmap_destroy (hashmap_t *hashmap, trafilo_state_free_fn state_free) |
| Graceful cleanup of the hashmap. | |
| void | hashmap_for_each (hashmap_t *hashmap, void(*fn)(bucket_node *bucket, void *arg), void *arg) |
| For each iteration for operations, calls passed function within lock protection. | |
| void | hashmap_unlock_bucket (hashmap_t *hashmap, const char *key) |
| Helper to unlock a locked node. | |
|
static |
|
static |
Bucket Indexing.
| m | Pointer to the hashmap |
| key | Pointer to the event key |
|
static |
FNV1A Hashing function.
| const | char * key to be hashed |
| hashmap_t * hashmap_create | ( | size_t | num_buckets | ) |
Create a hashmap.
| num_buckets | Number of buckets in the hashmap. |
| void hashmap_destroy | ( | hashmap_t * | hashmap, |
| trafilo_state_free_fn | state_free ) |
Graceful cleanup of the hashmap.
| hashmap | Pointer to the hashmap. |
| state_free | User specified state_free function. |
| bucket_node * hashmap_find_or_create | ( | hashmap_t * | hashmap, |
| const char * | key ) |
Find bucket for key; create if absent. Returns with bucket->bucket_lock LOCKED.
| hashmap | Target hashmap. |
| key | NUL-terminated string, bucket takes ownership. |
| void hashmap_for_each | ( | hashmap_t * | hashmap, |
| void(* | fn )(bucket_node *bucket, void *arg), | ||
| void * | arg ) |
For each iteration for operations, calls passed function within lock protection.
| hashmap | Pointer to the hashmap. |
| fn | Function with bucket_node and arguments. |
| arg | Arguments for the iterative function. |
| void hashmap_unlock_bucket | ( | hashmap_t * | hashmap, |
| const char * | key ) |
Helper to unlock a locked node.
| hashmap | Pointer to the hashmap. |
| key | The key that belongs to the node. |