Do you mean something like this?
struct Inner { int\* data; size_t size; size_t cachedIdx; }; struct ringbuffer3 { // No vector<int> [...] here, saves a cache line alignas(64) std::atomic<size_t> readIdx_{0}; alignas(64) Inner writeInner; alignas(64) std::atomic<size_t> writeIdx_{0}; alignas(64) Inner readInner; // Constructor ... };
(edit: formatting)
Do you mean something like this?
Am I understanding correctly?(edit: formatting)