#include "mm/memory.h"
-#include "threads/lock-common.h"
+#include "threads/mutex.hpp"
#include "toolbox/avl.h"
#include "toolbox/logging.h"
t = NEW(avl_tree_t);
+ t->mutex = Mutex_new();
t->root = NULL;
t->comparator = comparator;
t->entries = 0;
-#if defined(ENABLE_THREADS)
- /* create lock object for this tree */
-
- t->lock = NEW(java_object_t);
-
- LOCK_INIT_OBJECT_LOCK(t->lock);
-#endif
-
return t;
}
assert(tree);
assert(data);
- LOCK_MONITOR_ENTER(tree->lock);
+ Mutex_lock(tree->mutex);
/* if we don't have a root node, create one */
tree->entries++;
- LOCK_MONITOR_EXIT(tree->lock);
+ Mutex_unlock(tree->mutex);
/* insertion was ok */
assert(tree);
assert(data);
- LOCK_MONITOR_ENTER(tree->lock);
+ Mutex_lock(tree->mutex);
/* search the tree for the given node */
/* was the entry found? return it */
if (res == 0) {
- LOCK_MONITOR_EXIT(tree->lock);
+ Mutex_unlock(tree->mutex);
return node->data;
}
node = node->childs[(res < 0) ? AVL_LEFT : AVL_RIGHT];
}
- LOCK_MONITOR_EXIT(tree->lock);
+ Mutex_unlock(tree->mutex);
/* entry was not found, returning NULL */