Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

C++ has alignas since C++11 https://en.cppreference.com/w/cpp/language/alignas

and since C++17 has std::hardware_destructive_interference_size and std::hardware_constructive_interference_size https://en.cppreference.com/w/cpp/thread/hardware_destructiv...

which you can use together to either make sure that 2 variables are not in the same cache line (if you are making a lock-free list for example) or to make sure at compile-time that 2 variables are close enough to share a cache-line.



Thank you for pointing out that gem. Good to know!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: