[PATCH] D20579: [esan] Add circular buffer data structure

Mike Aizatsky via llvm-commits llvm-commits at lists.llvm.org
Tue May 24 14:56:24 PDT 2016


aizatsky added inline comments.

================
Comment at: lib/esan/esan_circular_buffer.h:20
@@ +19,3 @@
+// A circular buffer for POD data whose memory is allocated using mmap.
+template<typename T>
+class CircularBuffer {
----------------
Document that you need to call "initialize/free" rather than rely on constructors/destructors.

================
Comment at: lib/esan/esan_circular_buffer.h:26
@@ +25,3 @@
+  explicit CircularBuffer() {}
+  void initialize(uptr BufferCapacity) {
+    Capacity = BufferCapacity;
----------------
If you plan to have local-instances of this class (which I assume you don't), then please follow the tsan pattern with in-place new and

static ALIGNED(16) char thread_registry_placeholder[sizeof(ThreadRegistry)];

This would result in much better reusable utility class.


http://reviews.llvm.org/D20579





More information about the llvm-commits mailing list