/* src/toolbox/avl.c - AVL tree implementation
- Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
- C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
- E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
- J. Wenninger, Institut f. Computersprachen - TU Wien
+ Copyright (C) 1996-2005, 2006, 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
#include "vm/types.h"
-#include "mm/memory.h"
+#include "mm/memory.hpp"
-#include "threads/lock-common.h"
+#include "threads/mutex.hpp"
#include "toolbox/avl.h"
-#include "toolbox/logging.h"
+#include "toolbox/logging.hpp"
#include "vm/global.h"
-#include "vm/vm.h"
+#include "vm/vm.hpp"
/* avl_create ******************************************************************
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 */