parent
b09c303d52
commit
80f71e4393
|
@ -104,7 +104,11 @@ EFL_CHECK_THREADS
|
|||
if ! test "x${efl_have_threads}" = "xno" ; then
|
||||
EINA_CONFIGURE_HAVE_THREADS="#define EINA_HAVE_THREADS"
|
||||
fi
|
||||
if ! test "x${efl_have_pthread_barrier}" = "xno" ; then
|
||||
EINA_CONFIGURE_HAVE_PTHREAD_BARRIER="#define EINA_HAVE_PTHREAD_BARRIER"
|
||||
fi
|
||||
AC_SUBST(EINA_CONFIGURE_HAVE_THREADS)
|
||||
AC_SUBST(EINA_CONFIGURE_HAVE_PTHREAD_BARRIER)
|
||||
AM_CONDITIONAL([EINA_HAVE_THREADS], [! test "x${efl_have_threads}" = "xno"])
|
||||
|
||||
if test "x${efl_have_debug_threads}" = "xyes"; then
|
||||
|
@ -616,6 +620,7 @@ echo " Log support..........: ${enable_log}"
|
|||
echo " Thread Support.......: ${efl_have_threads}"
|
||||
if test "${efl_have_threads}" = "POSIX" ; then
|
||||
echo " spinlock...........: ${efl_have_posix_threads_spinlock}"
|
||||
echo " barrier............: ${efl_have_pthread_barrier}"
|
||||
echo " debug usage........: ${efl_have_debug_threads}"
|
||||
echo " on/off support.....: ${efl_have_on_off_threads}"
|
||||
fi
|
||||
|
|
|
@ -64,7 +64,8 @@ eina_refcount.h \
|
|||
eina_mmap.h \
|
||||
eina_xattr.h \
|
||||
eina_value.h \
|
||||
eina_inline_value.x
|
||||
eina_inline_value.x \
|
||||
eina_inline_lock_barrier.x
|
||||
|
||||
# Will be back for developper after 1.2.
|
||||
# eina_model.h
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
typedef struct _Eina_Barrier Eina_Barrier;
|
||||
|
||||
struct _Eina_Barrier
|
||||
{
|
||||
int needed, called;
|
||||
Eina_Lock lock, cond_lock;
|
||||
Eina_Condition cond;
|
||||
};
|
||||
|
||||
static inline Eina_Bool
|
||||
eina_barrier_new(Eina_Barrier *barrier, int needed)
|
||||
{
|
||||
barrier->needed = needed;
|
||||
barrier->called = 0;
|
||||
if (!eina_lock_new(&(barrier->lock)))
|
||||
return EINA_FALSE;
|
||||
if (!eina_lock_new(&(barrier->cond_lock)))
|
||||
return EINA_FALSE;
|
||||
if (!eina_condition_new(&(barrier->cond), &(barrier->cond_lock)))
|
||||
return EINA_FALSE;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static inline void
|
||||
eina_barrier_free(Eina_Barrier *barrier)
|
||||
{
|
||||
eina_condition_free(&(barrier->cond));
|
||||
eina_lock_free(&(barrier->cond_lock));
|
||||
eina_lock_free(&(barrier->lock));
|
||||
barrier->needed = 0;
|
||||
barrier->called = 0;
|
||||
}
|
||||
|
||||
static inline Eina_Bool
|
||||
eina_barrier_wait(Eina_Barrier *barrier)
|
||||
{
|
||||
eina_lock_take(&(barrier->lock));
|
||||
barrier->called++;
|
||||
if (barrier->called == barrier->needed)
|
||||
{
|
||||
barrier->called = 0;
|
||||
eina_condition_broadcast(&(barrier->cond));
|
||||
}
|
||||
else
|
||||
eina_condition_wait(&(barrier->cond));
|
||||
eina_lock_release(&(barrier->lock));
|
||||
return EINA_TRUE;
|
||||
}
|
Loading…
Reference in New Issue