From 37fdc6163ad2a672f42b7836e68461e851263cb9 Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Mon, 3 Apr 2006 14:02:26 +0000 Subject: [PATCH] fix thread locking --- lib/gdi/grc.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/gdi/grc.cpp b/lib/gdi/grc.cpp index d1380953..e4e4a861 100644 --- a/lib/gdi/grc.cpp +++ b/lib/gdi/grc.cpp @@ -102,23 +102,24 @@ void *gRC::thread() #ifndef SYNC_PAINT while (1) { - singleLock s(mutex); #else while (rp != wp) { #endif + pthread_mutex_lock(&mutex); if ( rp != wp ) { - gOpcode& o(queue[rp]); + gOpcode o(queue[rp]); + rp++; + if ( rp == MAXSIZE ) + rp=0; + pthread_mutex_unlock(&mutex); if (o.opcode==gOpcode::shutdown) break; else if (o.opcode==gOpcode::notify) need_notify = 1; else o.dc->exec(&o); - rp++; - if ( rp == MAXSIZE ) - rp=0; } else { @@ -130,6 +131,7 @@ void *gRC::thread() #ifndef SYNC_PAINT pthread_cond_wait(&cond, &mutex); #endif + pthread_mutex_unlock(&mutex); } } #ifndef SYNC_PAINT -- 2.30.2