eina: fix api to actually work as expected.

SVN revision: 58871
This commit is contained in:
Cedric BAIL 2011-04-24 16:49:48 +00:00
parent 702c047238
commit bd1337f4cd
9 changed files with 105 additions and 206 deletions

View File

@ -32,32 +32,32 @@ eina_lock_new(Eina_Lock *mutex)
}
static inline void
eina_lock_free(Eina_Lock mutex)
eina_lock_free(Eina_Lock *mutex)
{
pthread_mutex_destroy(&mutex);
pthread_mutex_destroy(mutex);
}
static inline Eina_Bool
eina_lock_take(Eina_Lock mutex)
eina_lock_take(Eina_Lock *mutex)
{
if (_threads_activated)
return (pthread_mutex_lock(&mutex) == 0) ? EINA_TRUE : EINA_FALSE;
return (pthread_mutex_lock(mutex) == 0) ? EINA_TRUE : EINA_FALSE;
return EINA_FALSE;
}
static inline Eina_Bool
eina_lock_take_try(Eina_Lock mutex)
eina_lock_take_try(Eina_Lock *mutex)
{
if (_threads_activated)
return (pthread_mutex_trylock(&mutex) == 0) ? EINA_TRUE : EINA_FALSE;
return (pthread_mutex_trylock(mutex) == 0) ? EINA_TRUE : EINA_FALSE;
return EINA_FALSE;
}
static inline Eina_Bool
eina_lock_release(Eina_Lock mutex)
eina_lock_release(Eina_Lock *mutex)
{
if (_threads_activated)
return (pthread_mutex_unlock(&mutex) == 0) ? EINA_TRUE : EINA_FALSE;
return (pthread_mutex_unlock(mutex) == 0) ? EINA_TRUE : EINA_FALSE;
return EINA_FALSE;
}

View File

@ -34,35 +34,35 @@ eina_lock_new(Eina_Lock *mutex)
}
static inline void
eina_lock_free(Eina_Lock mutex)
eina_lock_free(Eina_Lock *mutex)
{
DeleteCriticalSection(&mutex);
DeleteCriticalSection(mutex);
}
static inline Eina_Bool
eina_lock_take(Eina_Lock mutex)
eina_lock_take(Eina_Lock *mutex)
{
if (!_threads_activated) return EINA_FALSE;
EnterCriticalSection(&mutex);
EnterCriticalSection(mutex);
return EINA_TRUE;
}
static inline Eina_Bool
eina_lock_take_try(Eina_Lock mutex)
eina_lock_take_try(Eina_Lock *mutex)
{
if (!_threads_activated) return EINA_FALSE;
return TryEnterCriticalSection(&mutex) == 0 ? EINA_FALSE : EINA_TRUE;
return TryEnterCriticalSection(mutex) == 0 ? EINA_FALSE : EINA_TRUE;
}
static inline Eina_Bool
eina_lock_release(Eina_Lock mutex)
eina_lock_release(Eina_Lock *mutex)
{
if (!_threads_activated) return EINA_FALSE;
LeaveCriticalSection(&mutex);
LeaveCriticalSection(mutex);
return EINA_TRUE;
}

View File

@ -36,19 +36,19 @@ eina_lock_new(Eina_Lock *mutex)
}
static inline void
eina_lock_free(Eina_Lock mutex)
eina_lock_free(Eina_Lock *mutex)
{
CloseHandle(mutex);
CloseHandle(*mutex);
}
static inline Eina_Bool
eina_lock_take(Eina_Lock mutex)
eina_lock_take(Eina_Lock *mutex)
{
DWORD res;
if (!_threads_activated) return EINA_FALSE;
res = WaitForSingleObject(mutex, INFINITE);
res = WaitForSingleObject(*mutex, INFINITE);
if ((res == WAIT_ABANDONED) || (res == WAIT_FAILED))
return EINA_FALSE;
@ -56,17 +56,17 @@ eina_lock_take(Eina_Lock mutex)
}
static inline Eina_Bool
eina_lock_take_try(Eina_Lock mutex)
eina_lock_take_try(Eina_Lock *mutex)
{
return eina_lock_take(mutex);
return eina_lock_take(*mutex);
}
static inline Eina_Bool
eina_lock_release(Eina_Lock mutex)
eina_lock_release(Eina_Lock *mutex)
{
if (!_threads_activated) return EINA_FALSE;
return ReleaseMutex(mutex);
return ReleaseMutex(*mutex);
}

View File

@ -46,10 +46,10 @@
#endif
static inline Eina_Bool eina_lock_new(Eina_Lock *mutex);
static inline void eina_lock_free(Eina_Lock mutex);
static inline Eina_Bool eina_lock_take(Eina_Lock mutex);
static inline Eina_Bool eina_lock_take_try(Eina_Lock mutex);
static inline Eina_Bool eina_lock_release(Eina_Lock mutex);
static inline void eina_lock_free(Eina_Lock *mutex);
static inline Eina_Bool eina_lock_take(Eina_Lock *mutex);
static inline Eina_Bool eina_lock_take_try(Eina_Lock *mutex);
static inline Eina_Bool eina_lock_release(Eina_Lock *mutex);
/**
* @}

View File

@ -226,7 +226,7 @@ eina_shutdown(void)
{
_eina_shutdown_from_desc(_eina_desc_setup + _eina_desc_setup_len);
eina_lock_free(_mutex);
eina_lock_free(&_mutex);
}
return _eina_main_count;
@ -240,13 +240,13 @@ eina_threads_init(void)
int ret;
eina_lock_take(_mutex);
eina_lock_take(&_mutex);
++_eina_main_thread_count;
ret = _eina_main_thread_count;
if(_eina_main_thread_count > 1)
{
eina_lock_release(_mutex);
eina_lock_release(&_mutex);
return ret;
}
@ -254,7 +254,7 @@ eina_threads_init(void)
eina_log_threads_init();
_threads_activated = EINA_TRUE;
eina_lock_release(_mutex);
eina_lock_release(&_mutex);
return ret;
#else
@ -268,18 +268,18 @@ eina_threads_shutdown(void)
#ifdef EFL_HAVE_THREADS
int ret;
eina_lock_take(_mutex);
eina_lock_take(&_mutex);
ret = --_eina_main_thread_count;
if(_eina_main_thread_count > 0)
{
eina_lock_release(_mutex);
eina_lock_release(&_mutex);
return ret;
}
eina_share_common_threads_shutdown();
eina_log_threads_shutdown();
eina_lock_release(_mutex);
eina_lock_release(&_mutex);
_threads_activated = EINA_FALSE;

View File

@ -77,6 +77,7 @@
#include "eina_rbtree.h"
#include "eina_error.h"
#include "eina_log.h"
#include "eina_lock.h"
/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
#include "eina_safety_checks.h"
@ -169,27 +170,9 @@ struct _Eina_Share_Common_Head
Eina_Share_Common_Node builtin_node;
};
#ifdef EFL_HAVE_THREADS
Eina_Bool _share_common_threads_activated = EINA_FALSE;
# ifdef EFL_HAVE_POSIX_THREADS
static pthread_mutex_t _mutex_big = PTHREAD_MUTEX_INITIALIZER;
# define SHARE_COMMON_LOCK_BIG() if(_share_common_threads_activated) \
pthread_mutex_lock(&_mutex_big)
# define SHARE_COMMON_UNLOCK_BIG() if(_share_common_threads_activated) \
pthread_mutex_unlock(&_mutex_big)
# else /* EFL_HAVE_WIN32_THREADS */
static HANDLE _mutex_big = NULL;
# define SHARE_COMMON_LOCK_BIG() if(_share_common_threads_activated) \
WaitForSingleObject(_mutex_big, INFINITE)
# define SHARE_COMMON_UNLOCK_BIG() if(_share_common_threads_activated) \
ReleaseMutex(_mutex_big)
# endif /* EFL_HAVE_WIN32_THREADS */
#else /* EFL_HAVE_THREADS */
# define SHARE_COMMON_LOCK_BIG() do {} while (0)
# define SHARE_COMMON_UNLOCK_BIG() do {} while (0)
#endif
static Eina_Lock _mutex_big;
#ifdef EINA_SHARE_COMMON_USAGE
struct _Eina_Share_Common_Population
@ -269,7 +252,7 @@ _eina_share_common_population_stats(Eina_Share *share)
void
eina_share_common_population_add(Eina_Share *share, int slen)
{
SHARE_COMMON_LOCK_BIG();
eina_lock_take(&_mutex_big);
share->population.count++;
if (share->population.count > share->population.max)
@ -284,19 +267,19 @@ eina_share_common_population_add(Eina_Share *share, int slen)
share->population_group[slen].count;
}
SHARE_COMMON_UNLOCK_BIG();
eina_lock_release(&_mutex_big);
}
void
eina_share_common_population_del(Eina_Share *share, int slen)
{
SHARE_COMMON_LOCK_BIG();
eina_lock_take(&_mutex_big);
share->population.count--;
if (slen < 4)
share->population_group[slen].count--;
SHARE_COMMON_UNLOCK_BIG();
eina_lock_release(&_mutex_big);
}
static void
@ -571,7 +554,7 @@ eina_iterator_array_check(const Eina_Rbtree *rbtree __UNUSED__,
{
Eina_Share_Common_Node *node;
SHARE_COMMON_LOCK_BIG();
eina_lock_take(&_mutex_big);
fdata->used += sizeof(Eina_Share_Common_Head);
for (node = head->head; node; node = node->next)
@ -585,7 +568,7 @@ eina_iterator_array_check(const Eina_Rbtree *rbtree __UNUSED__,
fdata->unique++;
}
SHARE_COMMON_UNLOCK_BIG();
eina_lock_release(&_mutex_big);
return EINA_TRUE;
}
@ -652,6 +635,8 @@ eina_share_common_init(Eina_Share **_share,
EINA_MAGIC_SET(share->share, EINA_MAGIC_SHARE);
_eina_share_common_population_init(share);
eina_lock_new(&_mutex_big);
return EINA_TRUE;
}
@ -672,7 +657,7 @@ eina_share_common_shutdown(Eina_Share **_share)
unsigned int i;
Eina_Share *share = *_share;
SHARE_COMMON_LOCK_BIG();
eina_lock_take(&_mutex_big);
_eina_share_common_population_stats(share);
@ -694,7 +679,9 @@ eina_share_common_shutdown(Eina_Share **_share)
_eina_share_common_log_dom = -1;
}
SHARE_COMMON_UNLOCK_BIG();
eina_lock_release(&_mutex_big);
eina_lock_free(&_mutex_big);
free(*_share);
*_share = NULL;
@ -765,7 +752,7 @@ eina_share_common_add_length(Eina_Share *share,
hash_num = hash & 0xFF;
hash = (hash >> 8) & EINA_SHARE_COMMON_MASK;
SHARE_COMMON_LOCK_BIG();
eina_lock_take(&_mutex_big);
p_bucket = share->share->buckets + hash_num;
ed = _eina_share_common_find_hash(*p_bucket, hash);
@ -777,27 +764,27 @@ eina_share_common_add_length(Eina_Share *share,
str,
slen,
null_size);
SHARE_COMMON_UNLOCK_BIG();
eina_lock_release(&_mutex_big);
return s;
}
EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed, SHARE_COMMON_UNLOCK_BIG(), NULL);
EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed, eina_lock_release(&_mutex_big), NULL);
el = _eina_share_common_head_find(ed, str, slen);
if (el)
{
EINA_MAGIC_CHECK_SHARE_COMMON_NODE(el,
share->node_magic,
SHARE_COMMON_UNLOCK_BIG());
eina_lock_release(&_mutex_big));
el->references++;
SHARE_COMMON_UNLOCK_BIG();
eina_lock_release(&_mutex_big);
return el->str;
}
el = _eina_share_common_node_alloc(slen, null_size);
if (!el)
{
SHARE_COMMON_UNLOCK_BIG();
eina_lock_release(&_mutex_big);
return NULL;
}
@ -806,7 +793,7 @@ eina_share_common_add_length(Eina_Share *share,
ed->head = el;
_eina_share_common_population_head_add(share, ed);
SHARE_COMMON_UNLOCK_BIG();
eina_lock_release(&_mutex_big);
return el->str;
}
@ -819,13 +806,13 @@ eina_share_common_ref(Eina_Share *share, const char *str)
if (!str)
return NULL;
SHARE_COMMON_LOCK_BIG();
eina_lock_take(&_mutex_big);
node = _eina_share_common_node_from_str(str, share->node_magic);
if (!node) return str;
node->references++;
DBG("str=%p refs=%u", str, node->references);
SHARE_COMMON_UNLOCK_BIG();
eina_lock_release(&_mutex_big);
eina_share_common_population_add(share, node->length);
@ -845,7 +832,7 @@ eina_share_common_del(Eina_Share *share, const char *str)
if (!str)
return;
SHARE_COMMON_LOCK_BIG();
eina_lock_take(&_mutex_big);
node = _eina_share_common_node_from_str(str, share->node_magic);
if (!node)
@ -857,7 +844,7 @@ eina_share_common_del(Eina_Share *share, const char *str)
{
node->references--;
DBG("str=%p refs=%u", str, node->references);
SHARE_COMMON_UNLOCK_BIG();
eina_lock_release(&_mutex_big);
return;
}
@ -873,7 +860,7 @@ eina_share_common_del(Eina_Share *share, const char *str)
if (!ed)
goto on_error;
EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed, SHARE_COMMON_UNLOCK_BIG());
EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed, eina_lock_release(&_mutex_big));
if (!_eina_share_common_head_remove_node(ed, node))
goto on_error;
@ -886,12 +873,12 @@ eina_share_common_del(Eina_Share *share, const char *str)
else
_eina_share_common_population_head_del(share, ed);
SHARE_COMMON_UNLOCK_BIG();
eina_lock_release(&_mutex_big);
return;
on_error:
SHARE_COMMON_UNLOCK_BIG();
eina_lock_release(&_mutex_big);
/* possible segfault happened before here, but... */
CRITICAL("EEEK trying to del non-shared share_common \"%s\"", str);
}
@ -927,7 +914,7 @@ eina_share_common_dump(Eina_Share *share, void (*additional_dump)(
printf("DDD: len ref string\n");
printf("DDD:-------------------\n");
SHARE_COMMON_LOCK_BIG();
eina_lock_take(&_mutex_big);
for (i = 0; i < EINA_SHARE_COMMON_BUCKETS; i++)
{
if (!share->share->buckets[i])
@ -971,7 +958,7 @@ eina_share_common_dump(Eina_Share *share, void (*additional_dump)(
share->population_group[i].max);
#endif
SHARE_COMMON_UNLOCK_BIG();
eina_lock_release(&_mutex_big);
}
/**

View File

@ -47,10 +47,6 @@ void *alloca (size_t);
#include <stdio.h>
#include <string.h>
#ifdef EFL_HAVE_POSIX_THREADS
# include <pthread.h>
#endif
#ifdef HAVE_EVIL
# include <Evil.h>
#endif
@ -62,6 +58,7 @@ void *alloca (size_t);
#include "eina_error.h"
#include "eina_log.h"
#include "eina_stringshare.h"
#include "eina_lock.h"
/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
#include "eina_safety_checks.h"
@ -71,27 +68,8 @@ void *alloca (size_t);
static Eina_Share *stringshare_share;
static const char EINA_MAGIC_STRINGSHARE_NODE_STR[] = "Eina Stringshare Node";
#ifdef EFL_HAVE_THREADS
extern Eina_Bool _share_common_threads_activated;
# ifdef EFL_HAVE_POSIX_THREADS
static pthread_mutex_t _mutex_small = PTHREAD_MUTEX_INITIALIZER;
# define STRINGSHARE_LOCK_SMALL() if(_share_common_threads_activated) \
pthread_mutex_lock(&_mutex_small)
# define STRINGSHARE_UNLOCK_SMALL() if(_share_common_threads_activated) \
pthread_mutex_unlock(&_mutex_small)
# else /* EFL_HAVE_WIN32_THREADS */
static HANDLE _mutex_small = NULL;
# define STRINGSHARE_LOCK_SMALL() if(_share_common_threads_activated) \
WaitForSingleObject(_mutex_small, INFINITE)
# define STRINGSHARE_UNLOCK_SMALL() if(_share_common_threads_activated) \
ReleaseMutex(_mutex_small)
# endif /* EFL_HAVE_WIN32_THREADS */
#else /* EFL_HAVE_THREADS */
# define STRINGSHARE_LOCK_SMALL() do {} while (0)
# define STRINGSHARE_UNLOCK_SMALL() do {} while (0)
#endif
static Eina_Lock _mutex_small;
/* Stringshare optimizations */
static const unsigned char _eina_stringshare_single[512] = {
@ -418,6 +396,7 @@ error:
static void
_eina_stringshare_small_init(void)
{
eina_lock_new(&_mutex_small);
memset(&_eina_small_share, 0, sizeof(_eina_small_share));
}
@ -448,6 +427,8 @@ _eina_stringshare_small_shutdown(void)
free(bucket);
*p_bucket = NULL;
}
eina_lock_free(&_mutex_small);
}
static void
@ -579,9 +560,9 @@ eina_stringshare_del(const char *str)
else if (slen < 4)
{
eina_share_common_population_del(stringshare_share, slen);
STRINGSHARE_LOCK_SMALL();
eina_lock_take(&_mutex_small);
_eina_stringshare_small_del(str, slen);
STRINGSHARE_UNLOCK_SMALL();
eina_lock_release(&_mutex_small);
return;
}
@ -601,9 +582,9 @@ eina_stringshare_add_length(const char *str, unsigned int slen)
{
const char *s;
STRINGSHARE_LOCK_SMALL();
eina_lock_take(&_mutex_small);
s = _eina_stringshare_small_add(str, slen);
STRINGSHARE_UNLOCK_SMALL();
eina_lock_release(&_mutex_small);
return s;
}
@ -734,9 +715,9 @@ eina_stringshare_ref(const char *str)
const char *s;
eina_share_common_population_add(stringshare_share, slen);
STRINGSHARE_LOCK_SMALL();
eina_lock_take(&_mutex_small);
s = _eina_stringshare_small_add(str, slen);
STRINGSHARE_UNLOCK_SMALL();
eina_lock_release(&_mutex_small);
return s;
}

View File

@ -241,7 +241,7 @@ eina_chained_mempool_malloc(void *data, __UNUSED__ unsigned int size)
Chained_Pool *p = NULL;
void *mem;
if (!eina_lock_take(pool->mutex))
if (!eina_lock_take(&pool->mutex))
{
#ifdef EFL_DEBUG_THREADS
assert(pthread_equal(pool->self, pthread_self()));
@ -267,7 +267,7 @@ eina_chained_mempool_malloc(void *data, __UNUSED__ unsigned int size)
p = _eina_chained_mp_pool_new(pool);
if (!p)
{
eina_lock_release(pool->mutex);
eina_lock_release(&pool->mutex);
return NULL;
}
@ -278,7 +278,7 @@ eina_chained_mempool_malloc(void *data, __UNUSED__ unsigned int size)
mem = _eina_chained_mempool_alloc_in(pool, p);
eina_lock_release(pool->mutex);
eina_lock_release(&pool->mutex);
return mem;
}
@ -291,7 +291,7 @@ eina_chained_mempool_free(void *data, void *ptr)
Chained_Pool *p;
// look 4 pool
if (!eina_lock_take(pool->mutex))
if (!eina_lock_take(&pool->mutex))
{
#ifdef EFL_DEBUG_THREADS
assert(pthread_equal(pool->self, pthread_self()));
@ -322,7 +322,7 @@ eina_chained_mempool_free(void *data, void *ptr)
}
#endif
eina_lock_release(pool->mutex);
eina_lock_release(&pool->mutex);
return;
}
@ -336,7 +336,7 @@ eina_chained_mempool_repack(void *data,
Chained_Pool *tail;
/* FIXME: Improvement - per Chained_Pool lock */
if (!eina_lock_take(pool->mutex))
if (!eina_lock_take(&pool->mutex))
{
#ifdef EFL_DEBUG_THREADS
assert(pthread_equal(pool->self, pthread_self()));
@ -409,7 +409,7 @@ eina_chained_mempool_repack(void *data,
}
/* FIXME: improvement - reorder pool so that the most used one get in front */
eina_lock_release(pool->mutex);
eina_lock_release(&pool->mutex);
}
static void *
@ -494,7 +494,7 @@ eina_chained_mempool_shutdown(void *data)
VALGRIND_DESTROY_MEMPOOL(mp);
#endif
eina_lock_free(mp->mutex);
eina_lock_free(&mp->mutex);
#ifdef EFL_DEBUG_THREADS
assert(pthread_equal(mp->self, pthread_self()));

View File

@ -39,6 +39,7 @@
#include "eina_trash.h"
#include "eina_inlist.h"
#include "eina_log.h"
#include "eina_lock.h"
#ifndef NVALGRIND
# include <valgrind/memcheck.h>
@ -75,16 +76,10 @@ struct _One_Big
Eina_Trash *empty;
Eina_Inlist *over_list;
#ifdef EFL_HAVE_THREADS
# ifdef EFL_HAVE_POSIX_THREADS
# ifdef EFL_DEBUG_THREADS
#ifdef EFL_DEBUG_THREADS
pthread_t self;
# endif
pthread_mutex_t mutex;
# else
HANDLE mutex;
# endif
#endif
Eina_Lock mutex;
};
static void *
@ -93,22 +88,12 @@ eina_one_big_malloc(void *data, __UNUSED__ unsigned int size)
One_Big *pool = data;
unsigned char *mem = NULL;
#ifdef EFL_HAVE_THREADS
if (_threads_activated)
if (!eina_lock_take(&pool->mutex))
{
# ifdef EFL_HAVE_POSIX_THREADS
pthread_mutex_lock(&pool->mutex);
# else
WaitForSingleObject(pool->mutex, INFINITE);
# endif
}
# ifdef EFL_HAVE_POSIX_THREADS
# ifdef EFL_DEBUG_THREADS
else
assert(pthread_equal(pool->self, pthread_self()));
# endif
# endif
#ifdef EFL_DEBUG_THREADS
assert(pthread_equal(pool->self, pthread_self()));
#endif
}
if (pool->empty)
{
@ -158,16 +143,7 @@ eina_one_big_malloc(void *data, __UNUSED__ unsigned int size)
#endif
on_exit:
#ifdef EFL_HAVE_THREADS
if (_threads_activated)
{
# ifdef EFL_HAVE_POSIX_THREADS
pthread_mutex_unlock(&pool->mutex);
# else
ReleaseMutex(pool->mutex);
# endif
}
#endif
eina_lock_release(&pool->mutex);
#ifndef NVALGRIND
VALGRIND_MEMPOOL_ALLOC(pool, mem, pool->item_size);
@ -180,22 +156,12 @@ eina_one_big_free(void *data, void *ptr)
{
One_Big *pool = data;
#ifdef EFL_HAVE_THREADS
if (_threads_activated)
if (!eina_lock_take(&pool->mutex))
{
# ifdef EFL_HAVE_POSIX_THREADS
pthread_mutex_lock(&pool->mutex);
# else
WaitForSingleObject(pool->mutex, INFINITE);
# endif
}
# ifdef EFL_HAVE_POSIX_THREADS
# ifdef EFL_DEBUG_THREADS
else
assert(pthread_equal(pool->self, pthread_self()));
# endif
# endif
#ifdef EFL_DEBUG_THREADS
assert(pthread_equal(pool->self, pthread_self()));
#endif
}
if ((void *)pool->base <= ptr
&& ptr < (void *)(pool->base + (pool->max * pool->item_size)))
@ -228,16 +194,7 @@ eina_one_big_free(void *data, void *ptr)
VALGRIND_MEMPOOL_FREE(pool, ptr);
#endif
#ifdef EFL_HAVE_THREADS
if (_threads_activated)
{
# ifdef EFL_HAVE_POSIX_THREADS
pthread_mutex_unlock(&pool->mutex);
# else
ReleaseMutex(pool->mutex);
# endif
}
#endif
eina_lock_release(&pool->mutex);
}
static void *
@ -274,16 +231,10 @@ eina_one_big_init(const char *context,
memcpy((char *)pool->name, context, length);
}
#ifdef EFL_HAVE_THREADS
# ifdef EFL_HAVE_POSIX_THREADS
# ifdef EFL_DEBUG_THREADS
#ifdef EFL_DEBUG_THREADS
pool->self = pthread_self();
# endif
pthread_mutex_init(&pool->mutex, NULL);
# else
pool->mutex = CreateMutex(NULL, FALSE, NULL);
# endif
#endif
eina_lock_new(&pool->mutex);
#ifndef NVALGRIND
VALGRIND_CREATE_MEMPOOL(pool, 0, 1);
@ -298,22 +249,12 @@ eina_one_big_shutdown(void *data)
One_Big *pool = data;
if (!pool) return;
#ifdef EFL_HAVE_THREADS
if (_threads_activated)
if (!eina_lock_take(&pool->mutex))
{
# ifdef EFL_HAVE_POSIX_THREADS
pthread_mutex_lock(&pool->mutex);
# else
WaitForSingleObject(pool->mutex, INFINITE);
# endif
}
# ifdef EFL_HAVE_POSIX_THREADS
# ifdef EFL_DEBUG_THREADS
else
assert(pthread_equal(pool->self, pthread_self()));
# endif
# endif
#ifdef EFL_DEBUG_THREADS
assert(pthread_equal(pool->self, pthread_self()));
#endif
}
if (pool->over > 0)
{
@ -344,18 +285,8 @@ eina_one_big_shutdown(void *data)
if (pool->base) free(pool->base);
#ifdef EFL_HAVE_THREADS
if (_threads_activated)
{
# ifdef EFL_HAVE_POSIX_THREADS
pthread_mutex_unlock(&pool->mutex);
pthread_mutex_destroy(&pool->mutex);
# else
ReleaseMutex(pool->mutex);
CloseHandle(pool->mutex);
# endif
}
#endif
eina_lock_release(&pool->mutex);
eina_lock_free(&pool->mutex);
free(pool);
}