- try to optimize notify behaviour: notify only when queue is empty
authorFelix Domke <tmbinc@elitedvb.net>
Mon, 26 Sep 2005 17:34:19 +0000 (17:34 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Mon, 26 Sep 2005 17:34:19 +0000 (17:34 +0000)
lib/gdi/grc.cpp

index 05aaa6ffed8330a4bf117423719afa26a4fdc255..55d266c0359b2a59dbbffc0b094e3e1e5d95bc47 100644 (file)
@@ -1,5 +1,5 @@
 // for debugging use:
-#define SYNC_PAINT
+// #define SYNC_PAINT
 #include <unistd.h>
 #ifndef SYNC_PAINT
 #include <pthread.h>
@@ -55,6 +55,7 @@ gRC::~gRC()
 
 void *gRC::thread()
 {
+       int need_notify = 0;
 #ifndef SYNC_PAINT
        while (1)
 #else
@@ -66,12 +67,17 @@ void *gRC::thread()
                if (o.opcode==gOpcode::shutdown)
                        break;
                if (o.opcode==gOpcode::notify)
-               {
-                       m_notify_pump.send(1);
-               } else
+                       need_notify = 1;
+               else
                        o.dc->exec(&o);
                o.dc->Release();
                queue.dequeue();
+
+               if ((!queue.size()) && need_notify)
+               {
+                       need_notify = 0;
+                       m_notify_pump.send(1);
+               }
        }
 #ifndef SYNC_PAINT
        pthread_exit(0);