eina - add recursive mutex lock - apparently these are portable
new feature - recursive lock. same as normal lock just with recursive attr set @feature
This commit is contained in:
parent
c3d5ccf0f9
commit
1d26e61478
|
@ -186,6 +186,35 @@ fail_release:
|
|||
return ok;
|
||||
}
|
||||
|
||||
static inline Eina_Bool
|
||||
eina_lock_recursive_new(Eina_Lock *mutex)
|
||||
{
|
||||
pthread_mutexattr_t attr;
|
||||
Eina_Bool ok = EINA_FALSE;
|
||||
|
||||
#ifdef EINA_HAVE_DEBUG_THREADS
|
||||
if (!_eina_threads_activated)
|
||||
assert(pthread_equal(_eina_main_loop, pthread_self()));
|
||||
#endif
|
||||
|
||||
if (pthread_mutexattr_init(&attr) != 0)
|
||||
return EINA_FALSE;
|
||||
if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0)
|
||||
goto fail_release;
|
||||
#ifdef EINA_HAVE_DEBUG_THREADS
|
||||
if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK) != 0)
|
||||
goto fail_release;
|
||||
memset(mutex, 0, sizeof(Eina_Lock));
|
||||
#endif
|
||||
if (pthread_mutex_init(&(mutex->mutex), &attr) != 0)
|
||||
goto fail_release;
|
||||
|
||||
ok = EINA_TRUE;
|
||||
fail_release:
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
return ok;
|
||||
}
|
||||
|
||||
static inline void
|
||||
eina_lock_free(Eina_Lock *mutex)
|
||||
{
|
||||
|
|
|
@ -119,6 +119,22 @@ EAPI extern Eina_Error EINA_ERROR_NOT_MAIN_LOOP;
|
|||
*/
|
||||
static inline Eina_Bool eina_lock_new(Eina_Lock *mutex);
|
||||
|
||||
/**
|
||||
* @brief Initializes a new #Eina_Lock that is recursive.
|
||||
*
|
||||
* @param[in] mutex The #Eina_Lock structure to be initialized
|
||||
* @return #EINA_TRUE on success, #EINA_FALSE otherwise
|
||||
*
|
||||
* @details This function initializes an #Eina_Lock with appropriate values.
|
||||
* These values are platform dependent as is the structure of the
|
||||
* #Eina_Lock itself.
|
||||
*
|
||||
* @see eina_lock_new()
|
||||
* @see eina_lock_free()
|
||||
* @since 1.19
|
||||
*/
|
||||
static inline Eina_Bool eina_lock_recursive_new(Eina_Lock *mutex);
|
||||
|
||||
/**
|
||||
* @brief Deallocates an #Eina_Lock
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue