LV2 worker: prevent corruption of ringbuffer
[ardour.git] / libs / ardour / ardour / worker.h
index cdc3d1d06d46be03014bd53b23e391b5190bb756..4f3ff54bc10782898d32a711e7826f246732cc29 100644 (file)
@@ -75,6 +75,16 @@ public:
 
 private:
        void run();
+       /**
+          Peek in RB, get size and check if a block of 'size' is available.
+
+          Handle the unlikley edge-case, if we're called in between the
+          responder writing 'size' and 'data'.
+
+                @param rb the ringbuffer to check
+                @return true if the message is complete, false otherwise
+        */
+       bool verify_message_completeness(RingBuffer<uint8_t>* rb);
 
        Workee*                _workee;
        RingBuffer<uint8_t>*   _requests;
@@ -82,7 +92,8 @@ private:
        uint8_t*               _response;
        PBD::Semaphore         _sem;
        bool                   _exit;
-        Glib::Threads::Thread* _thread;
+       Glib::Threads::Thread* _thread;
+
 };
 
 } // namespace ARDOUR