forked from enlightenment/efl
- these data structures are never compiled with locking anymore so remove
the locks. SVN revision: 19732
This commit is contained in:
parent
f1bc839522
commit
a74f72c2ad
|
@ -52,86 +52,6 @@ extern "C" {
|
||||||
typedef int (*Ecore_Compare_Cb) (void *data1, void *data2);
|
typedef int (*Ecore_Compare_Cb) (void *data1, void *data2);
|
||||||
# define ECORE_COMPARE_CB(function) ((Ecore_Compare_Cb)function)
|
# define ECORE_COMPARE_CB(function) ((Ecore_Compare_Cb)function)
|
||||||
|
|
||||||
# ifdef HAVE_PTHREADS /* pthreads are installed */
|
|
||||||
|
|
||||||
# include <pthread.h>
|
|
||||||
|
|
||||||
# define ECORE_DECLARE_LOCKS \
|
|
||||||
struct { \
|
|
||||||
int readers; \
|
|
||||||
pthread_mutex_t readers_mutex; \
|
|
||||||
pthread_mutex_t writers_mutex; \
|
|
||||||
pthread_cond_t readers_cond; \
|
|
||||||
} locks
|
|
||||||
|
|
||||||
# define ECORE_INIT_LOCKS(structure) \
|
|
||||||
if (structure) { \
|
|
||||||
structure->readers = 0; \
|
|
||||||
pthread_mutex_init(&structure->locks.readers_mutex, NULL); \
|
|
||||||
pthread_mutex_init(&structure->locks.writers_mutex, NULL); \
|
|
||||||
pthread_cond_init(&structure->locks.readers_cond, NULL); \
|
|
||||||
}
|
|
||||||
|
|
||||||
# define ECORE_DESTROY_LOCKS(structure) \
|
|
||||||
if (structure) { \
|
|
||||||
pthread_mutex_destroy(&structure->locks.readers_mutex); \
|
|
||||||
pthread_mutex_destroy(&structure->locks.writers_mutex); \
|
|
||||||
pthread_cond_destroy(&structure->readers_cond); \
|
|
||||||
}
|
|
||||||
|
|
||||||
# define ECORE_READ_LOCK(structure) \
|
|
||||||
if (structure) { \
|
|
||||||
pthread_mutex_lock(&structure->locks.readers_mutex); \
|
|
||||||
structure->locks.readers++; \
|
|
||||||
pthread_mutex_unlock(&structure->locks.readers_mutex); \
|
|
||||||
}
|
|
||||||
|
|
||||||
# define ECORE_READ_UNLOCK(structure) \
|
|
||||||
if (structure) { \
|
|
||||||
pthread_mutex_lock(&structure->locks.readers_mutex); \
|
|
||||||
if (--structure->locks.readers == 0) \
|
|
||||||
pthread_cond_broadcast(&structure->locks.readers_cond); \
|
|
||||||
pthread_mutex_unlock(&structure->locks.readers_mutex); \
|
|
||||||
}
|
|
||||||
|
|
||||||
# define ECORE_WRITE_LOCK(structure) \
|
|
||||||
if (structure) { \
|
|
||||||
pthread_mutex_lock(&structure->locks.readers_mutex); \
|
|
||||||
pthread_mutex_lock(&structure->locks.writers_mutex); \
|
|
||||||
while (structure->locks.readers > 0) \
|
|
||||||
pthread_cond_wait(&structure->locks.readers_cond, \
|
|
||||||
&structure->locks.readers_mutex); \
|
|
||||||
pthread_mutex_unlock(&structure->locks.readers_mutex); \
|
|
||||||
}
|
|
||||||
|
|
||||||
# define ECORE_WRITE_UNLOCK(structure) \
|
|
||||||
if (structure) \
|
|
||||||
pthread_mutex_unlock(&structure->locks.writers_mutex); \
|
|
||||||
|
|
||||||
# define ECORE_THREAD_CREATE(function, arg) \
|
|
||||||
if (function) { \
|
|
||||||
pthread_t thread; \
|
|
||||||
pthread_create(&thread, NULL, function, arg); \
|
|
||||||
pthread_detach(thread); \
|
|
||||||
}
|
|
||||||
|
|
||||||
# define ECORE_NO_THREADS(function, arg)
|
|
||||||
|
|
||||||
# else /* No pthreads available */
|
|
||||||
|
|
||||||
# define ECORE_DECLARE_LOCKS
|
|
||||||
# define ECORE_INIT_LOCKS(structure)
|
|
||||||
# define ECORE_READ_LOCK(structure)
|
|
||||||
# define ECORE_READ_UNLOCK(structure)
|
|
||||||
# define ECORE_WRITE_LOCK(structure)
|
|
||||||
# define ECORE_WRITE_UNLOCK(structure)
|
|
||||||
# define ECORE_THREAD_CREATE(function, args)
|
|
||||||
# define ECORE_DESTROY_LOCKS(structure)
|
|
||||||
|
|
||||||
# define ECORE_NO_THREADS(function, arg) if (function) function(arg);
|
|
||||||
|
|
||||||
# endif /* HAVE_PTHREADS */
|
|
||||||
|
|
||||||
typedef struct _ecore_list Ecore_List;
|
typedef struct _ecore_list Ecore_List;
|
||||||
# define ECORE_LIST(list) ((Ecore_List *)list)
|
# define ECORE_LIST(list) ((Ecore_List *)list)
|
||||||
|
|
||||||
|
@ -141,8 +61,6 @@ extern "C" {
|
||||||
struct _ecore_list_node {
|
struct _ecore_list_node {
|
||||||
void *data;
|
void *data;
|
||||||
struct _ecore_list_node *next;
|
struct _ecore_list_node *next;
|
||||||
|
|
||||||
ECORE_DECLARE_LOCKS;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ecore_list {
|
struct _ecore_list {
|
||||||
|
@ -155,7 +73,6 @@ extern "C" {
|
||||||
int nodes; /* The number of nodes in the list */
|
int nodes; /* The number of nodes in the list */
|
||||||
int index; /* The position from the front of the
|
int index; /* The position from the front of the
|
||||||
list of current node */
|
list of current node */
|
||||||
ECORE_DECLARE_LOCKS;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EAPI int ecore_direct_compare(void *key1, void *key2);
|
EAPI int ecore_direct_compare(void *key1, void *key2);
|
||||||
|
@ -288,8 +205,6 @@ extern "C" {
|
||||||
Ecore_Hash_Node *next; /* Pointer to the next node in the bucket list */
|
Ecore_Hash_Node *next; /* Pointer to the next node in the bucket list */
|
||||||
void *key; /* The key for the data node */
|
void *key; /* The key for the data node */
|
||||||
void *value; /* The value associated with this node */
|
void *value; /* The value associated with this node */
|
||||||
|
|
||||||
ECORE_DECLARE_LOCKS;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _ecore_hash Ecore_Hash;
|
typedef struct _ecore_hash Ecore_Hash;
|
||||||
|
@ -308,8 +223,6 @@ extern "C" {
|
||||||
|
|
||||||
Ecore_Free_Cb free_key; /* The callback function to free key */
|
Ecore_Free_Cb free_key; /* The callback function to free key */
|
||||||
Ecore_Free_Cb free_value; /* The callback function to determine hash */
|
Ecore_Free_Cb free_value; /* The callback function to determine hash */
|
||||||
|
|
||||||
ECORE_DECLARE_LOCKS;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Create and initialize a hash */
|
/* Create and initialize a hash */
|
||||||
|
@ -460,8 +373,6 @@ extern "C" {
|
||||||
/* Book keeping information for quicker balancing of the tree */
|
/* Book keeping information for quicker balancing of the tree */
|
||||||
int max_right;
|
int max_right;
|
||||||
int max_left;
|
int max_left;
|
||||||
|
|
||||||
ECORE_DECLARE_LOCKS;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _Ecore_Tree Ecore_Tree;
|
typedef struct _Ecore_Tree Ecore_Tree;
|
||||||
|
@ -475,8 +386,6 @@ extern "C" {
|
||||||
|
|
||||||
/* Callback for freeing node data, default is NULL */
|
/* Callback for freeing node data, default is NULL */
|
||||||
Ecore_Free_Cb free_func;
|
Ecore_Free_Cb free_func;
|
||||||
|
|
||||||
ECORE_DECLARE_LOCKS;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Some basic tree functions */
|
/* Some basic tree functions */
|
||||||
|
|
|
@ -82,8 +82,6 @@ EAPI int ecore_hash_init(Ecore_Hash *hash, Ecore_Hash_Cb hash_func, Ecore_Compar
|
||||||
hash->buckets = (Ecore_Hash_Node **)calloc(ecore_prime_table[0],
|
hash->buckets = (Ecore_Hash_Node **)calloc(ecore_prime_table[0],
|
||||||
sizeof(Ecore_Hash_Node *));
|
sizeof(Ecore_Hash_Node *));
|
||||||
|
|
||||||
ECORE_INIT_LOCKS(hash);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,9 +103,7 @@ EAPI int ecore_hash_set_free_key(Ecore_Hash *hash, Ecore_Free_Cb function)
|
||||||
CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
|
CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
|
||||||
CHECK_PARAM_POINTER_RETURN("function", function, FALSE);
|
CHECK_PARAM_POINTER_RETURN("function", function, FALSE);
|
||||||
|
|
||||||
ECORE_WRITE_LOCK(hash);
|
|
||||||
hash->free_key = function;
|
hash->free_key = function;
|
||||||
ECORE_WRITE_UNLOCK(hash);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -124,9 +120,7 @@ EAPI int ecore_hash_set_free_value(Ecore_Hash *hash, Ecore_Free_Cb function)
|
||||||
CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
|
CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
|
||||||
CHECK_PARAM_POINTER_RETURN("function", function, FALSE);
|
CHECK_PARAM_POINTER_RETURN("function", function, FALSE);
|
||||||
|
|
||||||
ECORE_WRITE_LOCK(hash);
|
|
||||||
hash->free_value = function;
|
hash->free_value = function;
|
||||||
ECORE_WRITE_UNLOCK(hash);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +146,6 @@ EAPI int ecore_hash_set(Ecore_Hash *hash, void *key, void *value)
|
||||||
|
|
||||||
CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
|
CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
|
||||||
|
|
||||||
ECORE_WRITE_LOCK(hash);
|
|
||||||
node = _ecore_hash_get_node(hash, key);
|
node = _ecore_hash_get_node(hash, key);
|
||||||
if (node)
|
if (node)
|
||||||
node->value = value;
|
node->value = value;
|
||||||
|
@ -161,7 +154,6 @@ EAPI int ecore_hash_set(Ecore_Hash *hash, void *key, void *value)
|
||||||
if (node)
|
if (node)
|
||||||
ret = _ecore_hash_add_node(hash, node);
|
ret = _ecore_hash_add_node(hash, node);
|
||||||
}
|
}
|
||||||
ECORE_WRITE_UNLOCK(hash);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -178,8 +170,6 @@ EAPI void ecore_hash_destroy(Ecore_Hash *hash)
|
||||||
|
|
||||||
CHECK_PARAM_POINTER("hash", hash);
|
CHECK_PARAM_POINTER("hash", hash);
|
||||||
|
|
||||||
ECORE_WRITE_LOCK(hash);
|
|
||||||
|
|
||||||
if (hash->buckets) {
|
if (hash->buckets) {
|
||||||
while (i < ecore_prime_table[hash->size]) {
|
while (i < ecore_prime_table[hash->size]) {
|
||||||
if (hash->buckets[i]) {
|
if (hash->buckets[i]) {
|
||||||
|
@ -200,10 +190,6 @@ EAPI void ecore_hash_destroy(Ecore_Hash *hash)
|
||||||
|
|
||||||
FREE(hash->buckets);
|
FREE(hash->buckets);
|
||||||
}
|
}
|
||||||
|
|
||||||
ECORE_WRITE_UNLOCK(hash);
|
|
||||||
ECORE_DESTROY_LOCKS(hash);
|
|
||||||
|
|
||||||
FREE(hash);
|
FREE(hash);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -231,8 +217,6 @@ EAPI int ecore_hash_for_each_node(Ecore_Hash *hash, Ecore_For_Each for_each_func
|
||||||
CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
|
CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
|
||||||
CHECK_PARAM_POINTER_RETURN("for_each_func", for_each_func, FALSE);
|
CHECK_PARAM_POINTER_RETURN("for_each_func", for_each_func, FALSE);
|
||||||
|
|
||||||
ECORE_READ_LOCK(hash);
|
|
||||||
|
|
||||||
while (i < ecore_prime_table[hash->size]) {
|
while (i < ecore_prime_table[hash->size]) {
|
||||||
if (hash->buckets[i]) {
|
if (hash->buckets[i]) {
|
||||||
Ecore_Hash_Node *node;
|
Ecore_Hash_Node *node;
|
||||||
|
@ -244,8 +228,6 @@ EAPI int ecore_hash_for_each_node(Ecore_Hash *hash, Ecore_For_Each for_each_func
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ECORE_READ_UNLOCK(hash);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,10 +244,7 @@ EAPI Ecore_List *ecore_hash_keys(Ecore_Hash *hash)
|
||||||
|
|
||||||
CHECK_PARAM_POINTER_RETURN("hash", hash, NULL);
|
CHECK_PARAM_POINTER_RETURN("hash", hash, NULL);
|
||||||
|
|
||||||
ECORE_READ_LOCK(hash);
|
|
||||||
|
|
||||||
keys = ecore_list_new();
|
keys = ecore_list_new();
|
||||||
|
|
||||||
while (i < ecore_prime_table[hash->size]) {
|
while (i < ecore_prime_table[hash->size]) {
|
||||||
if (hash->buckets[i]) {
|
if (hash->buckets[i]) {
|
||||||
Ecore_Hash_Node *node;
|
Ecore_Hash_Node *node;
|
||||||
|
@ -276,11 +255,8 @@ EAPI Ecore_List *ecore_hash_keys(Ecore_Hash *hash)
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ecore_list_goto_first(keys);
|
ecore_list_goto_first(keys);
|
||||||
|
|
||||||
ECORE_READ_UNLOCK(hash);
|
|
||||||
|
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,9 +347,7 @@ EAPI void *ecore_hash_get(Ecore_Hash *hash, void *key)
|
||||||
if (!node)
|
if (!node)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ECORE_READ_LOCK(node);
|
|
||||||
data = node->value;
|
data = node->value;
|
||||||
ECORE_READ_UNLOCK(node);
|
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -397,8 +371,6 @@ EAPI void *ecore_hash_remove(Ecore_Hash *hash, void *key)
|
||||||
|
|
||||||
CHECK_PARAM_POINTER_RETURN("hash", hash, NULL);
|
CHECK_PARAM_POINTER_RETURN("hash", hash, NULL);
|
||||||
|
|
||||||
ECORE_WRITE_LOCK(hash);
|
|
||||||
|
|
||||||
/* Compute the position in the table */
|
/* Compute the position in the table */
|
||||||
if (!hash->hash_func)
|
if (!hash->hash_func)
|
||||||
hash_val = (unsigned int )key % ecore_prime_table[hash->size];
|
hash_val = (unsigned int )key % ecore_prime_table[hash->size];
|
||||||
|
@ -448,8 +420,6 @@ EAPI void *ecore_hash_remove(Ecore_Hash *hash, void *key)
|
||||||
if (ECORE_HASH_REDUCE(hash))
|
if (ECORE_HASH_REDUCE(hash))
|
||||||
_ecore_hash_decrease(hash);
|
_ecore_hash_decrease(hash);
|
||||||
|
|
||||||
ECORE_WRITE_UNLOCK(hash);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,10 +437,7 @@ _ecore_hash_get_node(Ecore_Hash *hash, void *key)
|
||||||
|
|
||||||
CHECK_PARAM_POINTER_RETURN("hash", hash, NULL);
|
CHECK_PARAM_POINTER_RETURN("hash", hash, NULL);
|
||||||
|
|
||||||
ECORE_READ_LOCK(hash);
|
|
||||||
|
|
||||||
if (!hash->buckets) {
|
if (!hash->buckets) {
|
||||||
ECORE_READ_UNLOCK(hash);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,8 +460,6 @@ _ecore_hash_get_node(Ecore_Hash *hash, void *key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ECORE_READ_UNLOCK(hash);
|
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,28 +476,22 @@ _ecore_hash_get_bucket(Ecore_Hash *hash, Ecore_Hash_Node *bucket, void *key)
|
||||||
Ecore_Hash_Node *prev = NULL;
|
Ecore_Hash_Node *prev = NULL;
|
||||||
Ecore_Hash_Node *node = NULL;
|
Ecore_Hash_Node *node = NULL;
|
||||||
|
|
||||||
ECORE_READ_LOCK(hash);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Traverse the list to find the desired node, if the node is in the
|
* Traverse the list to find the desired node, if the node is in the
|
||||||
* list, then return the node.
|
* list, then return the node.
|
||||||
*/
|
*/
|
||||||
if (hash->compare) {
|
if (hash->compare) {
|
||||||
for (node = bucket; node; node = node->next) {
|
for (node = bucket; node; node = node->next) {
|
||||||
ECORE_READ_LOCK(node);
|
|
||||||
if (hash->compare(node->key, key) == 0)
|
if (hash->compare(node->key, key) == 0)
|
||||||
break;
|
break;
|
||||||
prev = node;
|
prev = node;
|
||||||
ECORE_READ_UNLOCK(node);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (node = bucket; node; node = node->next) {
|
for (node = bucket; node; node = node->next) {
|
||||||
ECORE_READ_LOCK(node);
|
|
||||||
if (node->key == key)
|
if (node->key == key)
|
||||||
break;
|
break;
|
||||||
prev = node;
|
prev = node;
|
||||||
ECORE_READ_UNLOCK(node);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,17 +499,10 @@ _ecore_hash_get_bucket(Ecore_Hash *hash, Ecore_Hash_Node *bucket, void *key)
|
||||||
* Remove node from the list to replace it at the beginning.
|
* Remove node from the list to replace it at the beginning.
|
||||||
*/
|
*/
|
||||||
if (node && prev) {
|
if (node && prev) {
|
||||||
ECORE_WRITE_LOCK(prev);
|
|
||||||
prev->next = node->next;
|
prev->next = node->next;
|
||||||
ECORE_WRITE_UNLOCK(prev);
|
|
||||||
|
|
||||||
ECORE_WRITE_LOCK(node);
|
|
||||||
node->next = NULL;
|
node->next = NULL;
|
||||||
ECORE_WRITE_UNLOCK(node);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ECORE_READ_UNLOCK(hash);
|
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -719,7 +671,6 @@ _ecore_hash_node_init(Ecore_Hash_Node *node, void *key, void *value)
|
||||||
{
|
{
|
||||||
CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
|
CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
|
||||||
|
|
||||||
ECORE_INIT_LOCKS(node);
|
|
||||||
node->key = key;
|
node->key = key;
|
||||||
node->value = value;
|
node->value = value;
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,6 @@ EAPI int ecore_tree_init(Ecore_Tree * new_tree, Ecore_Compare_Cb compare_func)
|
||||||
else
|
else
|
||||||
new_tree->compare_func = compare_func;
|
new_tree->compare_func = compare_func;
|
||||||
|
|
||||||
ECORE_INIT_LOCKS(new_tree);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,9 +73,7 @@ EAPI int ecore_tree_set_free_cb(Ecore_Tree * tree, Ecore_Free_Cb free_func)
|
||||||
{
|
{
|
||||||
CHECK_PARAM_POINTER_RETURN("tree", tree, FALSE);
|
CHECK_PARAM_POINTER_RETURN("tree", tree, FALSE);
|
||||||
|
|
||||||
ECORE_WRITE_LOCK(tree);
|
|
||||||
tree->free_func = free_func;
|
tree->free_func = free_func;
|
||||||
ECORE_WRITE_UNLOCK(tree);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -99,8 +95,6 @@ EAPI int ecore_tree_node_init(Ecore_Tree_Node * new_node)
|
||||||
|
|
||||||
new_node->max_left = new_node->max_right = 0;
|
new_node->max_left = new_node->max_right = 0;
|
||||||
|
|
||||||
ECORE_INIT_LOCKS(new_node);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,12 +130,8 @@ EAPI int ecore_tree_node_destroy(Ecore_Tree_Node * node, Ecore_Free_Cb data_free
|
||||||
{
|
{
|
||||||
CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
|
CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
|
||||||
|
|
||||||
ECORE_WRITE_LOCK(node);
|
|
||||||
if (data_free)
|
if (data_free)
|
||||||
data_free(node->value);
|
data_free(node->value);
|
||||||
ECORE_WRITE_UNLOCK(node);
|
|
||||||
|
|
||||||
ECORE_DESTROY_LOCKS(node);
|
|
||||||
|
|
||||||
FREE(node);
|
FREE(node);
|
||||||
|
|
||||||
|
@ -159,9 +149,7 @@ EAPI int ecore_tree_node_value_set(Ecore_Tree_Node * node, void *value)
|
||||||
CHECK_PARAM_POINTER_RETURN("node", node,
|
CHECK_PARAM_POINTER_RETURN("node", node,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
ECORE_WRITE_LOCK(node);
|
|
||||||
node->value = value;
|
node->value = value;
|
||||||
ECORE_WRITE_UNLOCK(node);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -176,9 +164,7 @@ EAPI void *ecore_tree_node_value_get(Ecore_Tree_Node * node)
|
||||||
void *ret;
|
void *ret;
|
||||||
|
|
||||||
CHECK_PARAM_POINTER_RETURN("node", node, NULL);
|
CHECK_PARAM_POINTER_RETURN("node", node, NULL);
|
||||||
ECORE_READ_LOCK(node);
|
|
||||||
ret = node->value;
|
ret = node->value;
|
||||||
ECORE_READ_UNLOCK(node);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -193,9 +179,7 @@ EAPI int ecore_tree_node_key_set(Ecore_Tree_Node * node, void *key)
|
||||||
{
|
{
|
||||||
CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
|
CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
|
||||||
|
|
||||||
ECORE_WRITE_LOCK(node);
|
|
||||||
node->key = key;
|
node->key = key;
|
||||||
ECORE_WRITE_UNLOCK(node);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -211,9 +195,7 @@ EAPI void *ecore_tree_node_key_get(Ecore_Tree_Node * node)
|
||||||
void *ret;
|
void *ret;
|
||||||
|
|
||||||
CHECK_PARAM_POINTER_RETURN("node", node, NULL);
|
CHECK_PARAM_POINTER_RETURN("node", node, NULL);
|
||||||
ECORE_READ_LOCK(node);
|
|
||||||
ret = node->key;
|
ret = node->key;
|
||||||
ECORE_READ_UNLOCK(node);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -230,13 +212,10 @@ EAPI int ecore_tree_destroy(Ecore_Tree * tree)
|
||||||
|
|
||||||
CHECK_PARAM_POINTER_RETURN("tree", tree, FALSE);
|
CHECK_PARAM_POINTER_RETURN("tree", tree, FALSE);
|
||||||
|
|
||||||
ECORE_WRITE_LOCK(tree);
|
|
||||||
while ((node = tree->tree)) {
|
while ((node = tree->tree)) {
|
||||||
ecore_tree_remove_node(tree, node);
|
ecore_tree_remove_node(tree, node);
|
||||||
ecore_tree_node_destroy(node, tree->free_func);
|
ecore_tree_node_destroy(node, tree->free_func);
|
||||||
}
|
}
|
||||||
ECORE_WRITE_UNLOCK(tree);
|
|
||||||
ECORE_DESTROY_LOCKS(tree);
|
|
||||||
|
|
||||||
FREE(tree);
|
FREE(tree);
|
||||||
|
|
||||||
|
@ -256,9 +235,7 @@ EAPI Ecore_Tree_Node *ecore_tree_get_node(Ecore_Tree * tree, void *key)
|
||||||
|
|
||||||
CHECK_PARAM_POINTER_RETURN("tree", tree, NULL);
|
CHECK_PARAM_POINTER_RETURN("tree", tree, NULL);
|
||||||
|
|
||||||
ECORE_READ_LOCK(tree);
|
|
||||||
ret = tree_node_find(tree, key);
|
ret = tree_node_find(tree, key);
|
||||||
ECORE_READ_UNLOCK(tree);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -276,13 +253,8 @@ EAPI void *ecore_tree_get(Ecore_Tree * tree, void *key)
|
||||||
|
|
||||||
CHECK_PARAM_POINTER_RETURN("tree", tree, NULL);
|
CHECK_PARAM_POINTER_RETURN("tree", tree, NULL);
|
||||||
|
|
||||||
ECORE_READ_LOCK(tree);
|
|
||||||
node = tree_node_find(tree, key);
|
node = tree_node_find(tree, key);
|
||||||
ECORE_READ_UNLOCK(tree);
|
|
||||||
|
|
||||||
ECORE_READ_LOCK(node);
|
|
||||||
ret = (node ? node->value : NULL);
|
ret = (node ? node->value : NULL);
|
||||||
ECORE_READ_UNLOCK(node);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -300,26 +272,17 @@ EAPI void *ecore_tree_get_closest_larger(Ecore_Tree * tree, void *key)
|
||||||
|
|
||||||
CHECK_PARAM_POINTER_RETURN("tree", tree, NULL);
|
CHECK_PARAM_POINTER_RETURN("tree", tree, NULL);
|
||||||
|
|
||||||
ECORE_READ_LOCK(tree);
|
|
||||||
node = tree_node_find(tree, key);
|
node = tree_node_find(tree, key);
|
||||||
ECORE_READ_UNLOCK(tree);
|
|
||||||
|
|
||||||
if (node)
|
if (node)
|
||||||
return node;
|
return node;
|
||||||
|
|
||||||
ECORE_READ_LOCK(tree);
|
|
||||||
node = tree_node_find_parent(tree, key);
|
node = tree_node_find_parent(tree, key);
|
||||||
|
|
||||||
if (!node) {
|
if (!node) {
|
||||||
ECORE_READ_UNLOCK(tree);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ECORE_READ_LOCK(node);
|
|
||||||
if (tree->compare_func(node->key, key) < 0)
|
if (tree->compare_func(node->key, key) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
ECORE_READ_UNLOCK(node);
|
|
||||||
ECORE_READ_UNLOCK(tree);
|
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
@ -336,17 +299,11 @@ EAPI void *ecore_tree_get_closest_smaller(Ecore_Tree * tree, void *key)
|
||||||
|
|
||||||
CHECK_PARAM_POINTER_RETURN("tree", tree, NULL);
|
CHECK_PARAM_POINTER_RETURN("tree", tree, NULL);
|
||||||
|
|
||||||
ECORE_READ_LOCK(tree);
|
|
||||||
node = tree_node_find(tree, key);
|
node = tree_node_find(tree, key);
|
||||||
ECORE_READ_UNLOCK(tree);
|
|
||||||
|
|
||||||
if (node)
|
if (node)
|
||||||
return node;
|
return node;
|
||||||
|
|
||||||
ECORE_READ_LOCK(tree);
|
|
||||||
node = tree_node_find_parent(tree, key);
|
node = tree_node_find_parent(tree, key);
|
||||||
ECORE_READ_LOCK(tree);
|
|
||||||
|
|
||||||
if (node)
|
if (node)
|
||||||
node = node->right_child;
|
node = node->right_child;
|
||||||
|
|
||||||
|
@ -366,10 +323,7 @@ EAPI int ecore_tree_set(Ecore_Tree * tree, void *key, void *value)
|
||||||
|
|
||||||
CHECK_PARAM_POINTER_RETURN("tree", tree, FALSE);
|
CHECK_PARAM_POINTER_RETURN("tree", tree, FALSE);
|
||||||
|
|
||||||
ECORE_READ_LOCK(tree);
|
|
||||||
node = tree_node_find(tree, key);
|
node = tree_node_find(tree, key);
|
||||||
ECORE_READ_UNLOCK(tree);
|
|
||||||
|
|
||||||
if (!node) {
|
if (!node) {
|
||||||
node = ecore_tree_node_new();
|
node = ecore_tree_node_new();
|
||||||
ecore_tree_node_key_set(node, key);
|
ecore_tree_node_key_set(node, key);
|
||||||
|
@ -378,10 +332,8 @@ EAPI int ecore_tree_set(Ecore_Tree * tree, void *key, void *value)
|
||||||
}
|
}
|
||||||
ecore_tree_node_value_set(node, value);
|
ecore_tree_node_value_set(node, value);
|
||||||
|
|
||||||
ECORE_WRITE_LOCK(tree);
|
|
||||||
for (; node; node = node->parent)
|
for (; node; node = node->parent)
|
||||||
tree_node_balance(tree, node);
|
tree_node_balance(tree, node);
|
||||||
ECORE_WRITE_UNLOCK(tree);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue