Skip to content
Browse files

Add cacheline padding to prevent false sharing

  • Loading branch information...
1 parent 6f10826 commit c41096a1db8b6e5665b60cc176a6cc7fc5fd1f27 @rigtorp committed Nov 21, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 include/nmq.hpp
View
9 include/nmq.hpp
@@ -25,6 +25,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
+#include <unistd.h>
#include <cassert>
#include <cstring>
@@ -57,13 +58,15 @@ class context_t {
size_t _msg_size;
size_t _offset;
+ char _pad1[128];
// R/W access by the reader
// R/O access by the writer
- vo_uint _head;
-
+ vo_uint _head;
+
+ char _pad2[128];
// R/W access by the writer
// R/O access by the reader
- vo_uint _tail;
+ vo_uint _tail;
};
public:

0 comments on commit c41096a

Please sign in to comment.
Something went wrong with that request. Please try again.