Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ecore

Dir     : e17/libs/ecore/src/lib/ecore


Modified Files:
        Ecore_Data.h ecore_hash.c ecore_tree.c 


Log Message:
- these data structures are never compiled with locking anymore so remove
  the locks.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore/Ecore_Data.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- Ecore_Data.h        27 Dec 2005 17:17:30 -0000      1.19
+++ Ecore_Data.h        12 Jan 2006 03:01:58 -0000      1.20
@@ -52,86 +52,6 @@
    typedef int (*Ecore_Compare_Cb) (void *data1, void *data2);
 # 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;
 # define ECORE_LIST(list) ((Ecore_List *)list)
    
@@ -141,8 +61,6 @@
    struct _ecore_list_node {
       void *data;
       struct _ecore_list_node *next;
-      
-      ECORE_DECLARE_LOCKS;
    };
    
    struct _ecore_list {
@@ -155,7 +73,6 @@
       int nodes;               /* The number of nodes in the list */
       int index;               /* The position from the front of the
                                 list of current node */
-      ECORE_DECLARE_LOCKS;
    };
    
    EAPI int ecore_direct_compare(void *key1, void *key2);
@@ -288,8 +205,6 @@
       Ecore_Hash_Node *next; /* Pointer to the next node in the bucket list */
       void *key;            /* The key for the data node */
       void *value;          /* The value associated with this node */
-      
-      ECORE_DECLARE_LOCKS;
    };
    
    typedef struct _ecore_hash Ecore_Hash;
@@ -308,8 +223,6 @@
       
       Ecore_Free_Cb free_key;  /* The callback function to free key */
       Ecore_Free_Cb free_value;        /* The callback function to determine 
hash */
-      
-      ECORE_DECLARE_LOCKS;
    };
    
    /* Create and initialize a hash */
@@ -460,8 +373,6 @@
       /* Book keeping information for quicker balancing of the tree */
       int max_right;
       int max_left;
-      
-      ECORE_DECLARE_LOCKS;
    };
    
    typedef struct _Ecore_Tree Ecore_Tree;
@@ -475,8 +386,6 @@
       
       /* Callback for freeing node data, default is NULL */
       Ecore_Free_Cb free_func;
-      
-      ECORE_DECLARE_LOCKS;
    };
    
    /* Some basic tree functions */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore/ecore_hash.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -3 -r1.23 -r1.24
--- ecore_hash.c        6 Jan 2006 17:58:12 -0000       1.23
+++ ecore_hash.c        12 Jan 2006 03:01:58 -0000      1.24
@@ -82,8 +82,6 @@
        hash->buckets = (Ecore_Hash_Node **)calloc(ecore_prime_table[0],
                        sizeof(Ecore_Hash_Node *));
 
-       ECORE_INIT_LOCKS(hash);
-
        return TRUE;
 }
 
@@ -105,9 +103,7 @@
        CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
        CHECK_PARAM_POINTER_RETURN("function", function, FALSE);
 
-       ECORE_WRITE_LOCK(hash);
        hash->free_key = function;
-       ECORE_WRITE_UNLOCK(hash);
 
        return TRUE;
 }
@@ -124,9 +120,7 @@
        CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
        CHECK_PARAM_POINTER_RETURN("function", function, FALSE);
 
-       ECORE_WRITE_LOCK(hash);
        hash->free_value = function;
-       ECORE_WRITE_UNLOCK(hash);
 
        return TRUE;
 }
@@ -152,7 +146,6 @@
 
        CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
 
-       ECORE_WRITE_LOCK(hash);
        node = _ecore_hash_get_node(hash, key);
        if (node)
                node->value = value;
@@ -161,7 +154,6 @@
                if (node)
                        ret = _ecore_hash_add_node(hash, node);
        }
-       ECORE_WRITE_UNLOCK(hash);
 
        return ret;
 }
@@ -178,8 +170,6 @@
 
        CHECK_PARAM_POINTER("hash", hash);
 
-       ECORE_WRITE_LOCK(hash);
-
        if (hash->buckets) {
                while (i < ecore_prime_table[hash->size]) {
                        if (hash->buckets[i]) {
@@ -200,10 +190,6 @@
 
                FREE(hash->buckets);
        }
-
-       ECORE_WRITE_UNLOCK(hash);
-       ECORE_DESTROY_LOCKS(hash);
-
        FREE(hash);
 
        return;
@@ -231,8 +217,6 @@
        CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
        CHECK_PARAM_POINTER_RETURN("for_each_func", for_each_func, FALSE);
 
-       ECORE_READ_LOCK(hash);
-
        while (i < ecore_prime_table[hash->size]) {
                if (hash->buckets[i]) {
                        Ecore_Hash_Node *node;
@@ -244,8 +228,6 @@
                i++;
        }
 
-       ECORE_READ_UNLOCK(hash);
-
        return TRUE;
 }
 
@@ -262,10 +244,7 @@
 
        CHECK_PARAM_POINTER_RETURN("hash", hash, NULL);
 
-       ECORE_READ_LOCK(hash);
-
        keys = ecore_list_new();
-
        while (i < ecore_prime_table[hash->size]) {
                if (hash->buckets[i]) {
                        Ecore_Hash_Node *node;
@@ -276,11 +255,8 @@
                }
                i++;
        }
-
        ecore_list_goto_first(keys);
 
-       ECORE_READ_UNLOCK(hash);
-
        return keys;
 }
 
@@ -371,9 +347,7 @@
        if (!node)
                return NULL;
 
-       ECORE_READ_LOCK(node);
        data = node->value;
-       ECORE_READ_UNLOCK(node);
 
        return data;
 }
@@ -397,8 +371,6 @@
 
        CHECK_PARAM_POINTER_RETURN("hash", hash, NULL);
 
-       ECORE_WRITE_LOCK(hash);
-
        /* Compute the position in the table */
        if (!hash->hash_func)
                hash_val = (unsigned int )key % ecore_prime_table[hash->size];
@@ -448,8 +420,6 @@
        if (ECORE_HASH_REDUCE(hash))
                _ecore_hash_decrease(hash);
 
-       ECORE_WRITE_UNLOCK(hash);
-
        return ret;
 }
 
@@ -467,10 +437,7 @@
 
        CHECK_PARAM_POINTER_RETURN("hash", hash, NULL);
 
-       ECORE_READ_LOCK(hash);
-
        if (!hash->buckets) {
-               ECORE_READ_UNLOCK(hash);
                return NULL;
        }
 
@@ -493,8 +460,6 @@
                }
        }
 
-       ECORE_READ_UNLOCK(hash);
-
        return node;
 }
 
@@ -511,28 +476,22 @@
        Ecore_Hash_Node *prev = NULL;
        Ecore_Hash_Node *node = NULL;
 
-       ECORE_READ_LOCK(hash);
-
        /*
         * Traverse the list to find the desired node, if the node is in the
         * list, then return the node.
         */
        if (hash->compare) {
                for (node = bucket; node; node = node->next) {
-                       ECORE_READ_LOCK(node);
                        if (hash->compare(node->key, key) == 0)
                                break;
                        prev = node;
-                       ECORE_READ_UNLOCK(node);
                }
        }
        else {
                for (node = bucket; node; node = node->next) {
-                       ECORE_READ_LOCK(node);
                        if (node->key == key)
                                break;
                        prev = node;
-                       ECORE_READ_UNLOCK(node);
                }
        }
 
@@ -540,17 +499,10 @@
         * Remove node from the list to replace it at the beginning.
         */
        if (node && prev) {
-               ECORE_WRITE_LOCK(prev);
                prev->next = node->next;
-               ECORE_WRITE_UNLOCK(prev);
-
-               ECORE_WRITE_LOCK(node);
                node->next = NULL;
-               ECORE_WRITE_UNLOCK(node);
        }
 
-       ECORE_READ_UNLOCK(hash);
-
        return node;
 }
 
@@ -719,7 +671,6 @@
 {
        CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
 
-       ECORE_INIT_LOCKS(node);
        node->key = key;
        node->value = value;
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore/ecore_tree.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- ecore_tree.c        6 Jan 2006 17:58:12 -0000       1.8
+++ ecore_tree.c        12 Jan 2006 03:01:58 -0000      1.9
@@ -60,8 +60,6 @@
        else
                new_tree->compare_func = compare_func;
 
-       ECORE_INIT_LOCKS(new_tree);
-
        return TRUE;
 }
 
@@ -75,9 +73,7 @@
 {
        CHECK_PARAM_POINTER_RETURN("tree", tree, FALSE);
 
-       ECORE_WRITE_LOCK(tree);
        tree->free_func = free_func;
-       ECORE_WRITE_UNLOCK(tree);
 
        return TRUE;
 }
@@ -99,8 +95,6 @@
 
        new_node->max_left = new_node->max_right = 0;
 
-       ECORE_INIT_LOCKS(new_node);
-
        return TRUE;
 }
 
@@ -136,12 +130,8 @@
 {
        CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
 
-       ECORE_WRITE_LOCK(node);
        if (data_free)
                data_free(node->value);
-       ECORE_WRITE_UNLOCK(node);
-
-       ECORE_DESTROY_LOCKS(node);
 
        FREE(node);
 
@@ -159,9 +149,7 @@
        CHECK_PARAM_POINTER_RETURN("node", node,
                                   FALSE);
 
-       ECORE_WRITE_LOCK(node);
        node->value = value;
-       ECORE_WRITE_UNLOCK(node);
 
        return TRUE;
 }
@@ -176,9 +164,7 @@
        void *ret;
 
        CHECK_PARAM_POINTER_RETURN("node", node, NULL);
-       ECORE_READ_LOCK(node);
        ret = node->value;
-       ECORE_READ_UNLOCK(node);
 
        return ret;
 }
@@ -193,9 +179,7 @@
 {
        CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
 
-       ECORE_WRITE_LOCK(node);
        node->key = key;
-       ECORE_WRITE_UNLOCK(node);
 
        return TRUE;
 }
@@ -211,9 +195,7 @@
        void *ret;
 
        CHECK_PARAM_POINTER_RETURN("node", node, NULL);
-       ECORE_READ_LOCK(node);
        ret = node->key;
-       ECORE_READ_UNLOCK(node);
 
        return ret;
 }
@@ -230,13 +212,10 @@
 
        CHECK_PARAM_POINTER_RETURN("tree", tree, FALSE);
 
-       ECORE_WRITE_LOCK(tree);
        while ((node = tree->tree)) {
                ecore_tree_remove_node(tree, node);
                ecore_tree_node_destroy(node, tree->free_func);
        }
-       ECORE_WRITE_UNLOCK(tree);
-       ECORE_DESTROY_LOCKS(tree);
 
        FREE(tree);
 
@@ -256,9 +235,7 @@
 
        CHECK_PARAM_POINTER_RETURN("tree", tree, NULL);
 
-       ECORE_READ_LOCK(tree);
        ret = tree_node_find(tree, key);
-       ECORE_READ_UNLOCK(tree);
 
        return ret;
 }
@@ -276,13 +253,8 @@
 
        CHECK_PARAM_POINTER_RETURN("tree", tree, NULL);
 
-       ECORE_READ_LOCK(tree);
        node = tree_node_find(tree, key);
-       ECORE_READ_UNLOCK(tree);
-
-       ECORE_READ_LOCK(node);
        ret = (node ? node->value : NULL);
-       ECORE_READ_UNLOCK(node);
 
        return ret;
 }
@@ -300,26 +272,17 @@
 
        CHECK_PARAM_POINTER_RETURN("tree", tree, NULL);
 
-       ECORE_READ_LOCK(tree);
        node = tree_node_find(tree, key);
-       ECORE_READ_UNLOCK(tree);
-
        if (node)
                return node;
 
-       ECORE_READ_LOCK(tree);
        node = tree_node_find_parent(tree, key);
-
        if (!node) {
-               ECORE_READ_UNLOCK(tree);
                return NULL;
        }
 
-       ECORE_READ_LOCK(node);
        if (tree->compare_func(node->key, key) < 0)
                return NULL;
-       ECORE_READ_UNLOCK(node);
-       ECORE_READ_UNLOCK(tree);
 
        return node;
 }
@@ -336,17 +299,11 @@
 
        CHECK_PARAM_POINTER_RETURN("tree", tree, NULL);
 
-       ECORE_READ_LOCK(tree);
        node = tree_node_find(tree, key);
-       ECORE_READ_UNLOCK(tree);
-
        if (node)
                return node;
 
-       ECORE_READ_LOCK(tree);
        node = tree_node_find_parent(tree, key);
-       ECORE_READ_LOCK(tree);
-
        if (node)
                node = node->right_child;
 
@@ -366,10 +323,7 @@
 
        CHECK_PARAM_POINTER_RETURN("tree", tree, FALSE);
 
-       ECORE_READ_LOCK(tree);
        node = tree_node_find(tree, key);
-       ECORE_READ_UNLOCK(tree);
-
        if (!node) {
                node = ecore_tree_node_new();
                ecore_tree_node_key_set(node, key);
@@ -378,10 +332,8 @@
        }
        ecore_tree_node_value_set(node, value);
 
-       ECORE_WRITE_LOCK(tree);
        for (; node; node = node->parent)
                tree_node_balance(tree, node);
-       ECORE_WRITE_UNLOCK(tree);
 
        return TRUE;
 }




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to