Re: [PATCH] Add thread safety to cRingBufferLinear

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09.02.23 23:31, Patrick Lerda wrote:
...
This is really related to the C++ thread safety model, the patch below fixes the main cRingBufferLinear issue:

diff --git a/ringbuffer.h b/ringbuffer.h
index 746fc51..a3fa499 100644
--- a/ringbuffer.h
+++ b/ringbuffer.h
@@ -10,6 +10,7 @@
  #ifndef __RINGBUFFER_H
  #define __RINGBUFFER_H

+#include <atomic>
  #include "thread.h"
  #include "tools.h"

@@ -58,7 +59,8 @@ public:
    static void PrintDebugRBL(void);
  #endif
  private:
-  int margin, head, tail;
+  int margin;
+  std::atomic_int head, tail;
    int gotten;
    uchar *buffer;
    char *description;

Is there an actual, reproducable, real world problem that makes this necessary?
I mean without any "thread sanitizer" etc.

Klaus


_______________________________________________
vdr mailing list
vdr@xxxxxxxxxxx
https://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr




[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux