aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2002-12-09 08:23:58 +0800
committerMichael Zucci <zucchi@src.gnome.org>2002-12-09 08:23:58 +0800
commitc43c83145ab56f5422665f8a9c8468033064ce95 (patch)
tree81f0c2df0c66b54201ec55a45dfd1ff17d7abf57
parent84fabde6ba83eb4dcae2aa428cfcfe220bc800db (diff)
downloadgsoc2013-evolution-c43c83145ab56f5422665f8a9c8468033064ce95.tar.gz
gsoc2013-evolution-c43c83145ab56f5422665f8a9c8468033064ce95.tar.zst
gsoc2013-evolution-c43c83145ab56f5422665f8a9c8468033064ce95.zip
Allow an e-mutex to be used with standard condition variables.
2002-12-07 Not Zed <NotZed@Ximian.com> * e-msgport.c (e_mutex_cond_wait): Allow an e-mutex to be used with standard condition variables. svn path=/trunk/; revision=19055
-rw-r--r--e-util/ChangeLog5
-rw-r--r--e-util/e-msgport.c19
-rw-r--r--e-util/e-msgport.h2
3 files changed, 26 insertions, 0 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index af7e2f3ef8..edad602d6e 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,8 @@
+2002-12-07 Not Zed <NotZed@Ximian.com>
+
+ * e-msgport.c (e_mutex_cond_wait): Allow an e-mutex to be used
+ with standard condition variables.
+
2002-12-06 Chris Toshok <toshok@ximian.com>
* e-categories-master-list-wombat.c (ecmlw_load): change to a more
diff --git a/e-util/e-msgport.c b/e-util/e-msgport.c
index 34a6391ad7..dc55156dc7 100644
--- a/e-util/e-msgport.c
+++ b/e-util/e-msgport.c
@@ -906,6 +906,25 @@ void e_mutex_assert_locked(EMutex *m)
pthread_mutex_unlock(&m->mutex);
}
+int e_mutex_cond_wait(void *vcond, EMutex *m)
+{
+ int ret;
+ pthread_cond_t *cond = vcond;
+
+ switch(m->type) {
+ case E_MUTEX_SIMPLE:
+ return pthread_cond_wait(cond, &m->mutex);
+ case E_MUTEX_REC:
+ if (pthread_mutex_lock(&m->mutex) == -1)
+ return -1;
+ g_assert(m->owner == pthread_self());
+ ret = pthread_cond_wait(cond, &m->mutex);
+ g_assert(m->owner == pthread_self());
+ pthread_mutex_unlock(&m->mutex);
+ return ret;
+ }
+}
+
#ifdef STANDALONE
EMsgPort *server_port;
diff --git a/e-util/e-msgport.h b/e-util/e-msgport.h
index 6fc01efb14..8d4e0c20f7 100644
--- a/e-util/e-msgport.h
+++ b/e-util/e-msgport.h
@@ -82,5 +82,7 @@ int e_mutex_destroy(EMutex *m);
int e_mutex_lock(EMutex *m);
int e_mutex_unlock(EMutex *m);
void e_mutex_assert_locked(EMutex *m);
+/* this uses pthread cond's */
+int e_mutex_cond_wait(void *cond, EMutex *m);
#endif