diff --git a/src/misc.h b/src/misc.h index 9f250b6e..be9b4c38 100644 --- a/src/misc.h +++ b/src/misc.h @@ -563,6 +563,23 @@ public: void deallocate(T* p, std::size_t ) { std_aligned_free(p); } }; +template +class CacheLineAlignedAllocator { +public: + using value_type = T; + + constexpr static uint64_t cache_line_size = 64; + + CacheLineAlignedAllocator() {} + CacheLineAlignedAllocator(const CacheLineAlignedAllocator&) {} + CacheLineAlignedAllocator(CacheLineAlignedAllocator&&) {} + + template CacheLineAlignedAllocator(const CacheLineAlignedAllocator&) {} + + T* allocate(std::size_t n) { return (T*)std_aligned_alloc(cache_line_size, n * sizeof(T)); } + void deallocate(T* p, std::size_t) { std_aligned_free(p); } +}; + // -------------------- // Dependency Wrapper // --------------------