diff options
author | Lennart Weller <lhw@ring0.de> | 2016-09-05 08:27:21 +0000 |
---|---|---|
committer | Lennart Weller <lhw@ring0.de> | 2016-09-05 08:27:21 +0000 |
commit | 1746898cefcb17f58b5cf27b4dad3d28236f1152 (patch) | |
tree | 9207f191cf39bbd077a1e1c73d6e82123e2fc710 /src/dictionary.h | |
parent | Imported Upstream version 1.2.0+dfsg (diff) | |
download | netdata-1746898cefcb17f58b5cf27b4dad3d28236f1152.tar.xz netdata-1746898cefcb17f58b5cf27b4dad3d28236f1152.zip |
Imported Upstream version 1.3.0+dfsgupstream/1.3.0+dfsg
Diffstat (limited to 'src/dictionary.h')
-rw-r--r-- | src/dictionary.h | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/src/dictionary.h b/src/dictionary.h index 575f2827..6bebbfa8 100644 --- a/src/dictionary.h +++ b/src/dictionary.h @@ -1,45 +1,44 @@ -#include <pthread.h> - -#include "web_buffer.h" -#include "avl.h" - #ifndef NETDATA_DICTIONARY_H #define NETDATA_DICTIONARY_H 1 +struct dictionary_stats { + unsigned long long inserts; + unsigned long long deletes; + unsigned long long searches; + unsigned long long entries; +}; + typedef struct name_value { - avl avl; // the index - this has to be first! + avl avl; // the index - this has to be first! - uint32_t hash; // a simple hash to speed up searching - // we first compare hashes, and only if the hashes are equal we do string comparisons + uint32_t hash; // a simple hash to speed up searching + // we first compare hashes, and only if the hashes are equal we do string comparisons - char *name; - void *value; + char *name; + void *value; } NAME_VALUE; typedef struct dictionary { - avl_tree values_index; - - uint8_t flags; + avl_tree values_index; - unsigned long long inserts; - unsigned long long deletes; - unsigned long long searches; - unsigned long long entries; + uint8_t flags; - pthread_rwlock_t rwlock; + struct dictionary_stats *stats; + pthread_rwlock_t *rwlock; } DICTIONARY; -#define DICTIONARY_FLAG_DEFAULT 0x00000000 -#define DICTIONARY_FLAG_SINGLE_THREADED 0x00000001 -#define DICTIONARY_FLAG_VALUE_LINK_DONT_CLONE 0x00000002 -#define DICTIONARY_FLAG_NAME_LINK_DONT_CLONE 0x00000004 +#define DICTIONARY_FLAG_DEFAULT 0x00000000 +#define DICTIONARY_FLAG_SINGLE_THREADED 0x00000001 +#define DICTIONARY_FLAG_VALUE_LINK_DONT_CLONE 0x00000002 +#define DICTIONARY_FLAG_NAME_LINK_DONT_CLONE 0x00000004 +#define DICTIONARY_FLAG_WITH_STATISTICS 0x00000008 -extern DICTIONARY *dictionary_create(uint32_t flags); +extern DICTIONARY *dictionary_create(uint8_t flags); extern void dictionary_destroy(DICTIONARY *dict); extern void *dictionary_set(DICTIONARY *dict, const char *name, void *value, size_t value_len); extern void *dictionary_get(DICTIONARY *dict, const char *name); extern int dictionary_del(DICTIONARY *dict, const char *name); -extern int dictionary_get_all(DICTIONARY *dict, int (*callback)(void *entry, void *data), void *data); +extern int dictionary_get_all(DICTIONARY *dict, int (*callback)(void *entry, void *d), void *data); #endif /* NETDATA_DICTIONARY_H */ |