]> arthur.barton.de Git - netdata.git/blobdiff - src/avl.h
apps.plugin: major new features and optimizations: now it reports system usage (all...
[netdata.git] / src / avl.h
old mode 100755 (executable)
new mode 100644 (file)
index 8071a87..2d1fbc5
--- a/src/avl.h
+++ b/src/avl.h
  * Released under GNU General Public License (GPL) version 2
  *
  */
-#include <pthread.h>
-
 #ifndef _AVL_H
 #define _AVL_H 1
 
+#ifndef AVL_WITHOUT_PTHREADS
+#include <pthread.h>
+#endif /* AVL_WITHOUT_PTHREADS */
+
+// #define AVL_LOCK_WITH_MUTEX 1
+
 /* Data structures */
 
 /* One element of the AVL tree */
@@ -30,7 +34,14 @@ typedef struct avl {
 typedef struct avl_tree {
        avl* root;
        int (*compar)(void* a, void* b);
+
+#ifndef AVL_WITHOUT_PTHREADS
+#ifdef AVL_LOCK_WITH_MUTEX
+       pthread_mutex_t mutex;
+#else /* AVL_LOCK_WITH_MUTEX */
        pthread_rwlock_t rwlock;
+#endif /* AVL_LOCK_WITH_MUTEX */
+#endif /* AVL_WITHOUT_PTHREADS */
 } avl_tree;
 
 /* Public methods */
@@ -58,13 +69,13 @@ int avl_removeroot(avl_tree* t);
  * returns the last value returned by iterator or 0 if there were no calls
  * Warning: a<=b must hold
  */
-int avl_range(avl_tree* t, avl* a, avl* b, int (*iter)(avl* a), avl** ret);
+int avl_range(avl_tree* t, avl* a, avl* b, int (*iter)(avl*), avl** ret);
 
 /* Iterate through elements in t equal to a
  * for each element calls iter(a) until it returns 0
  * returns the last value returned by iterator or 0 if there were no calls
  */
-int avl_search(avl_tree* t, avl* a, int (*iter)(avl* a), avl** ret);
+int avl_search(avl_tree* t, avl* a, int (*iter)(avl*), avl** ret);
 
 /* Initialize the avl_tree
  */