forked from enlightenment/efl
use mutex instead of spinlock. older pthreads dont have spinlocks. also this
uses the same mutex macros used by the mutex on font objects, so it makes it a bit simpler. old code is commented out for reference. SVN revision: 39458
This commit is contained in:
parent
0dd51fa0cf
commit
bb0e068fa1
|
@ -174,9 +174,12 @@ evas_module_init(void)
|
|||
em->handle = NULL;
|
||||
em->data = NULL;
|
||||
em->loaded = 0;
|
||||
#if defined(BUILD_PTHREAD) && defined(BUILD_ASYNC_PRELOAD)
|
||||
pthread_spin_init(&em->lock, PTHREAD_PROCESS_PRIVATE);
|
||||
#ifdef BUILD_ASYNC_PRELOAD
|
||||
LKI(em->lock);
|
||||
#endif
|
||||
//#if defined(BUILD_PTHREAD) && defined(BUILD_ASYNC_PRELOAD)
|
||||
// pthread_mutex_init(&em->lock, NULL);
|
||||
//#endif
|
||||
if (em->type == EVAS_MODULE_TYPE_ENGINE)
|
||||
{
|
||||
Evas_Module_Engine *eme;
|
||||
|
@ -309,35 +312,50 @@ evas_module_unload(Evas_Module *em)
|
|||
em->func.close = NULL;
|
||||
em->api = NULL;
|
||||
em->loaded = 0;
|
||||
#if defined(BUILD_PTHREAD) && defined(BUILD_ASYNC_PRELOAD)
|
||||
pthread_spin_destroy(&em->lock);
|
||||
#ifdef BUILD_ASYNC_PRELOAD
|
||||
LKD(em->lock);
|
||||
#endif
|
||||
//#if defined(BUILD_PTHREAD) && defined(BUILD_ASYNC_PRELOAD)
|
||||
// pthread_mutex_destroy(&em->lock);
|
||||
//#endif
|
||||
}
|
||||
|
||||
void
|
||||
evas_module_ref(Evas_Module *em)
|
||||
{
|
||||
#if defined(BUILD_PTHREAD) && defined(BUILD_ASYNC_PRELOAD)
|
||||
pthread_spin_lock(&em->lock);
|
||||
#ifdef BUILD_ASYNC_PRELOAD
|
||||
LKL(em->lock);
|
||||
#endif
|
||||
//#if defined(BUILD_PTHREAD) && defined(BUILD_ASYNC_PRELOAD)
|
||||
// pthread_mutex_lock(&em->lock);
|
||||
//#endif
|
||||
em->ref++;
|
||||
/* printf("M: %s ref++ = %i\n", em->name, em->ref); */
|
||||
#if defined(BUILD_PTHREAD) && defined(BUILD_ASYNC_PRELOAD)
|
||||
pthread_spin_unlock(&em->lock);
|
||||
#ifdef BUILD_ASYNC_PRELOAD
|
||||
LKU(em->lock);
|
||||
#endif
|
||||
//#if defined(BUILD_PTHREAD) && defined(BUILD_ASYNC_PRELOAD)
|
||||
// pthread_mutex_unlock(&em->lock);
|
||||
//#endif
|
||||
}
|
||||
|
||||
void
|
||||
evas_module_unref(Evas_Module *em)
|
||||
{
|
||||
#if defined(BUILD_PTHREAD) && defined(BUILD_ASYNC_PRELOAD)
|
||||
pthread_spin_lock(&em->lock);
|
||||
#ifdef BUILD_ASYNC_PRELOAD
|
||||
LKL(em->lock);
|
||||
#endif
|
||||
//#if defined(BUILD_PTHREAD) && defined(BUILD_ASYNC_PRELOAD)
|
||||
// pthread_mutex_lock(&em->lock);
|
||||
//#endif
|
||||
em->ref--;
|
||||
/* printf("M: %s ref-- = %i\n", em->name, em->ref); */
|
||||
#if defined(BUILD_PTHREAD) && defined(BUILD_ASYNC_PRELOAD)
|
||||
pthread_spin_unlock(&em->lock);
|
||||
#ifdef BUILD_ASYNC_PRELOAD
|
||||
LKU(em->lock);
|
||||
#endif
|
||||
//#if defined(BUILD_PTHREAD) && defined(BUILD_ASYNC_PRELOAD)
|
||||
// pthread_mutex_unlock(&em->lock);
|
||||
//#endif
|
||||
}
|
||||
|
||||
static int use_count = 0;
|
||||
|
|
|
@ -50,8 +50,8 @@ struct _Evas_Module
|
|||
int ref; /* how many refs */
|
||||
int last_used; /* the cycle count when it was last used */
|
||||
|
||||
#if defined(HAVE_PTHREAD_H) && defined(BUILD_ASYNC_PRELOAD) && _POSIX_SPIN_LOCKS > -1
|
||||
pthread_spinlock_t lock;
|
||||
#if defined(HAVE_PTHREAD_H) && defined(BUILD_ASYNC_PRELOAD)
|
||||
pthread_mutex_t lock;
|
||||
#endif
|
||||
|
||||
unsigned char loaded : 1;
|
||||
|
|
Loading…
Reference in New Issue