fix thread locking
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 3 Apr 2006 14:02:26 +0000 (14:02 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 3 Apr 2006 14:02:26 +0000 (14:02 +0000)
lib/gdi/grc.cpp

index d13809530f22b1f663e356ac9e7767e4bdf3bb8a..e4e4a8615c5149933d063b954be6fb76225a8412 100644 (file)
@@ -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