summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-10-17 03:55:24 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-10-17 03:55:24 +0000
commit80f71e4393e819cdd234fbf1d07e332694bdcd71 (patch)
treee57bc08d5133041bda7927bce4815c3c8282282f
parentb09c303d52e72ead82aea568b4a216e2e0d1e2e5 (diff)
add eina barrier stuff.
SVN revision: 78099
-rw-r--r--legacy/eina/configure.ac5
-rw-r--r--legacy/eina/src/include/Makefile.am3
-rw-r--r--legacy/eina/src/include/eina_inline_lock_barrier.x48
3 files changed, 55 insertions, 1 deletions
diff --git a/legacy/eina/configure.ac b/legacy/eina/configure.ac
index 1011bece00..a548ff70f7 100644
--- a/legacy/eina/configure.ac
+++ b/legacy/eina/configure.ac
@@ -104,7 +104,11 @@ EFL_CHECK_THREADS
104if ! test "x${efl_have_threads}" = "xno" ; then 104if ! test "x${efl_have_threads}" = "xno" ; then
105 EINA_CONFIGURE_HAVE_THREADS="#define EINA_HAVE_THREADS" 105 EINA_CONFIGURE_HAVE_THREADS="#define EINA_HAVE_THREADS"
106fi 106fi
107if ! test "x${efl_have_pthread_barrier}" = "xno" ; then
108 EINA_CONFIGURE_HAVE_PTHREAD_BARRIER="#define EINA_HAVE_PTHREAD_BARRIER"
109fi
107AC_SUBST(EINA_CONFIGURE_HAVE_THREADS) 110AC_SUBST(EINA_CONFIGURE_HAVE_THREADS)
111AC_SUBST(EINA_CONFIGURE_HAVE_PTHREAD_BARRIER)
108AM_CONDITIONAL([EINA_HAVE_THREADS], [! test "x${efl_have_threads}" = "xno"]) 112AM_CONDITIONAL([EINA_HAVE_THREADS], [! test "x${efl_have_threads}" = "xno"])
109 113
110if test "x${efl_have_debug_threads}" = "xyes"; then 114if test "x${efl_have_debug_threads}" = "xyes"; then
@@ -616,6 +620,7 @@ echo " Log support..........: ${enable_log}"
616echo " Thread Support.......: ${efl_have_threads}" 620echo " Thread Support.......: ${efl_have_threads}"
617if test "${efl_have_threads}" = "POSIX" ; then 621if test "${efl_have_threads}" = "POSIX" ; then
618echo " spinlock...........: ${efl_have_posix_threads_spinlock}" 622echo " spinlock...........: ${efl_have_posix_threads_spinlock}"
623echo " barrier............: ${efl_have_pthread_barrier}"
619echo " debug usage........: ${efl_have_debug_threads}" 624echo " debug usage........: ${efl_have_debug_threads}"
620echo " on/off support.....: ${efl_have_on_off_threads}" 625echo " on/off support.....: ${efl_have_on_off_threads}"
621fi 626fi
diff --git a/legacy/eina/src/include/Makefile.am b/legacy/eina/src/include/Makefile.am
index ba64e38f8a..2bc629f8b2 100644
--- a/legacy/eina/src/include/Makefile.am
+++ b/legacy/eina/src/include/Makefile.am
@@ -64,7 +64,8 @@ eina_refcount.h \
64eina_mmap.h \ 64eina_mmap.h \
65eina_xattr.h \ 65eina_xattr.h \
66eina_value.h \ 66eina_value.h \
67eina_inline_value.x 67eina_inline_value.x \
68eina_inline_lock_barrier.x
68 69
69# Will be back for developper after 1.2. 70# Will be back for developper after 1.2.
70# eina_model.h 71# eina_model.h
diff --git a/legacy/eina/src/include/eina_inline_lock_barrier.x b/legacy/eina/src/include/eina_inline_lock_barrier.x
new file mode 100644
index 0000000000..536e26c6d5
--- /dev/null
+++ b/legacy/eina/src/include/eina_inline_lock_barrier.x
@@ -0,0 +1,48 @@
1typedef struct _Eina_Barrier Eina_Barrier;
2
3struct _Eina_Barrier
4{
5 int needed, called;
6 Eina_Lock lock, cond_lock;
7 Eina_Condition cond;
8};
9
10static inline Eina_Bool
11eina_barrier_new(Eina_Barrier *barrier, int needed)
12{
13 barrier->needed = needed;
14 barrier->called = 0;
15 if (!eina_lock_new(&(barrier->lock)))
16 return EINA_FALSE;
17 if (!eina_lock_new(&(barrier->cond_lock)))
18 return EINA_FALSE;
19 if (!eina_condition_new(&(barrier->cond), &(barrier->cond_lock)))
20 return EINA_FALSE;
21 return EINA_TRUE;
22}
23
24static inline void
25eina_barrier_free(Eina_Barrier *barrier)
26{
27 eina_condition_free(&(barrier->cond));
28 eina_lock_free(&(barrier->cond_lock));
29 eina_lock_free(&(barrier->lock));
30 barrier->needed = 0;
31 barrier->called = 0;
32}
33
34static inline Eina_Bool
35eina_barrier_wait(Eina_Barrier *barrier)
36{
37 eina_lock_take(&(barrier->lock));
38 barrier->called++;
39 if (barrier->called == barrier->needed)
40 {
41 barrier->called = 0;
42 eina_condition_broadcast(&(barrier->cond));
43 }
44 else
45 eina_condition_wait(&(barrier->cond));
46 eina_lock_release(&(barrier->lock));
47 return EINA_TRUE;
48}