From: raster Date: Mon, 2 May 2011 08:24:06 +0000 (+0000) Subject: formalise eina lock results to be equivalent to true/false with added X-Git-Tag: 2.0_alpha~70^2~78 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=26dd600e9809cc0d7ce9d57a9a3d68b069350275;p=framework%2Fuifw%2Feina.git formalise eina lock results to be equivalent to true/false with added deadlock for try. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@59101 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/include/eina_inline_lock_posix.x b/src/include/eina_inline_lock_posix.x index a003c4b..5de513f 100644 --- a/src/include/eina_inline_lock_posix.x +++ b/src/include/eina_inline_lock_posix.x @@ -51,6 +51,19 @@ struct _Eina_Lock #endif }; +#ifdef EINA_LOCK_DEBUG +# define EINA_LOCK_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, { 0 }, 0, 0 } +#else +# define EINA_LOCK_INITIALIZER { PTHREAD_MUTEX_INITIALIZER } +#endif + +typedef enum +{ + EINA_LOCK_FAIL = EINA_FALSE, + EINA_LOCK_SUCCEED = EINA_TRUE, + EINA_LOCK_DEADLOCK +} Eina_Lock_Result; + EAPI extern Eina_Bool _eina_threads_activated; #ifdef EINA_HAVE_DEBUG_THREADS @@ -59,7 +72,7 @@ EAPI extern Eina_Bool _eina_threads_activated; EAPI extern int _eina_threads_debug; #endif -static inline Eina_Bool +static inline Eina_Lock_Result eina_lock_new(Eina_Lock *mutex) { pthread_mutexattr_t attr; @@ -94,7 +107,7 @@ eina_lock_free(Eina_Lock *mutex) #endif } -static inline Eina_Bool +static inline Eina_Lock_Result eina_lock_take(Eina_Lock *mutex) { Eina_Bool ret; @@ -128,7 +141,7 @@ eina_lock_take(Eina_Lock *mutex) return ret; } -static inline Eina_Bool +static inline Eina_Lock_Result eina_lock_take_try(Eina_Lock *mutex) { Eina_Bool ret = EINA_FALSE; @@ -139,7 +152,7 @@ eina_lock_take_try(Eina_Lock *mutex) else if (ok == EDEADLK) { printf("ERROR ERROR: DEADLOCK on lock %p\n", mutex); - ret = 2; // magic + ret = EINA_LOCK_DEADLOCK; // magic } #ifdef EINA_LOCK_DEBUG if (ret == EINA_TRUE) @@ -152,7 +165,7 @@ eina_lock_take_try(Eina_Lock *mutex) return ret; } -static inline Eina_Bool +static inline Eina_Lock_Result eina_lock_release(Eina_Lock *mutex) { Eina_Bool ret;