From c43c83145ab56f5422665f8a9c8468033064ce95 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Mon, 9 Dec 2002 00:23:58 +0000 Subject: Allow an e-mutex to be used with standard condition variables. 2002-12-07 Not Zed * e-msgport.c (e_mutex_cond_wait): Allow an e-mutex to be used with standard condition variables. svn path=/trunk/; revision=19055 --- e-util/e-msgport.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'e-util/e-msgport.c') 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; -- cgit