void hashmap_destroy(hashmap_t *hashmap, trafilo_state_free_fn state_free)
Graceful cleanup of the hashmap.
Definition hashmap.c:106
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.
Definition hashmap.c:138
hashmap_t * hashmap_create(size_t num_buckets)
Create a hashmap.
Definition hashmap.c:5
void hashmap_unlock_bucket(hashmap_t *hashmap, const char *key)
Helper to unlock a locked node.
Definition hashmap.c:154
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.
Definition hashmap.c:76
A bucket node of the hashtable.
Definition hashmap.h:14
void * state
Definition hashmap.h:16
struct timespec last_event_ts
Definition hashmap.h:20
sliding_window_t * window
Definition hashmap.h:17
char * key
Definition hashmap.h:15
struct bucket_node * next
Definition hashmap.h:19
The hashmap structure.
Definition hashmap.h:26
size_t num_buckets
Definition hashmap.h:29
pthread_mutex_t * locks
Definition hashmap.h:28
bucket_node ** buckets
Definition hashmap.h:27
A sliding sampling window represented as a linked list of timestamps.
Definition window.h:19
void(* trafilo_state_free_fn)(void *user_state)
Free the user defined state, when a bucket is evicted.
Definition trafilo.h:76