and this too
authordiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 10 Aug 2010 12:00:36 +0000 (12:00 +0000)
committerdiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 10 Aug 2010 12:00:36 +0000 (12:00 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@50960 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/include/eina_inline_array.x

index 75e499f..9ca22d6 100644 (file)
 #ifndef EINA_INLINE_ARRAY_X_
 #define EINA_INLINE_ARRAY_X_
 
-#ifdef EINA_RWLOCKS_ENABLED
-# include <pthread.h>
-#endif
-
-extern Eina_Bool _eina_array_threadsafety;
 /**
  * @cond LOCAL
  */
@@ -61,29 +56,19 @@ eina_array_push(Eina_Array *array, const void *data)
 {
    if (!data) return EINA_FALSE;
 
-#ifdef EINA_RWLOCKS_ENABLED
-   if (_eina_array_threadsafety)
-     pthread_rwlock_wrlock(&array->lock);
-#endif
+   if (!eina_array_wrlock(array))
+     return EINA_FALSE;
 
    if (EINA_UNLIKELY((array->count + 1) > array->total))
      if (!eina_array_grow(array))
        {
-
-#ifdef EINA_RWLOCKS_ENABLED
-          if (_eina_array_threadsafety)
-            pthread_rwlock_unlock(&array->lock);
-#endif
-
+          eina_array_unlock(array);
           return EINA_FALSE;
        }
 
    array->data[array->count++] = (void*) data;
 
-#ifdef EINA_RWLOCKS_ENABLED
-   if (_eina_array_threadsafety)
-     pthread_rwlock_unlock(&array->lock);
-#endif
+   eina_array_unlock(array);
 
    return EINA_TRUE;
 }
@@ -105,27 +90,17 @@ eina_array_pop(Eina_Array *array)
 {
    void *ret = NULL;
    
-#ifdef EINA_RWLOCKS_ENABLED
-   if (_eina_array_threadsafety)
-     pthread_rwlock_wrlock(&array->lock);
-#endif
+   if (!eina_array_wrlock(array))
+     return NULL;
 
    if (array->count <= 0)
      {
-      
-#ifdef EINA_RWLOCKS_ENABLED
-   if (_eina_array_threadsafety)
-     pthread_rwlock_unlock(&array->lock);
-#endif
-
+        eina_array_unlock(array);
         return NULL;
      }
    ret = array->data[--array->count];
    
-#ifdef EINA_RWLOCKS_ENABLED
-   if (_eina_array_threadsafety)
-     pthread_rwlock_unlock(&array->lock);
-#endif
+   eina_array_unlock(array);
 
    return ret;
 }
@@ -142,23 +117,9 @@ eina_array_pop(Eina_Array *array)
  * idx. If it is @c NULL or invalid, the program may crash.
  */
 static inline void *
-eina_array_data_get(Eina_Array *array, unsigned int idx)
+eina_array_data_get(const Eina_Array *array, unsigned int idx)
 {
-   void *ret = NULL;
-
-#ifdef EINA_RWLOCKS_ENABLED
-   if (_eina_array_threadsafety)
-     pthread_rwlock_rdlock(&array->lock);
-#endif
-
-   ret = array->data[idx];
-
-#ifdef EINA_RWLOCKS_ENABLED
-   if (_eina_array_threadsafety)
-     pthread_rwlock_unlock(&array->lock);
-#endif
-
-   return ret;
+   return array->data[idx];
 }
 
 /**
@@ -173,19 +134,9 @@ eina_array_data_get(Eina_Array *array, unsigned int idx)
  * idx. If it is @c NULL or invalid, the program may crash.
  */
 static inline void
-eina_array_data_set(Eina_Array *array, unsigned int idx, const void *data)
+eina_array_data_set(const Eina_Array *array, unsigned int idx, const void *data)
 {
-#ifdef EINA_RWLOCKS_ENABLED
-   if (_eina_array_threadsafety)
-     pthread_rwlock_wrlock(&array->lock);
-#endif
-
    array->data[idx] = (void*) data;
-
-#ifdef EINA_RWLOCKS_ENABLED
-   if (_eina_array_threadsafety)
-     pthread_rwlock_unlock(&array->lock);
-#endif
 }
 
 /**
@@ -199,19 +150,9 @@ eina_array_data_set(Eina_Array *array, unsigned int idx, const void *data)
  * @c NULL or invalid, the program may crash.
  */
 static inline unsigned int
-eina_array_count_get(Eina_Array *array)
+eina_array_count_get(const Eina_Array *array)
 {
-#ifdef EINA_RWLOCKS_ENABLED
-   if (_eina_array_threadsafety)
-     pthread_rwlock_rdlock(&array->lock);
-#endif
-
    return array->count;
-
-#ifdef EINA_RWLOCKS_ENABLED
-   if (_eina_array_threadsafety)
-     pthread_rwlock_unlock(&array->lock);
-#endif
 }
 
 /**